3.js 332 B

123456789101112131415161718
  1. const app = new Vue({
  2. el: '#root',
  3. data: {
  4. names: ['Joe', 'Mary', 'Jane', 'Jack'],
  5. },
  6. mounted() {
  7. document.querySelector('#button').addEventListener('click', () => {
  8. "use strict";
  9. const name = document.querySelector('#input');
  10. app.names.push(name.value);
  11. name.value = '';
  12. });
  13. }
  14. });