手動掛載$mount()
如果沒有掛載的話,沒有關聯的 DOM 元素。是獲取不到$el的。
https://vuejs.org/v2/api/#vm-mount
var MyComponent = Vue.extend({
template: '<div>Hello!</div>' }) // create and mount to #app (will replace #app) new MyComponent().$mount('#app') // the above is the same as: new MyComponent({ el: '#app' }) // or, render off-document and append afterwards: var component = new MyComponent().$mount() document.getElementById('app').appendChild(component.$el)