2018-08-28T13:31:43Z||2018-08-28T13:31:43Z
使用new Vue()
, render
和$mount
:
import Vue from 'vue';
import App from './App.vue';
new Vue({
render: (h) => h(App, {
props: {
name: 'Haha',
},
}),
}).$mount('#app');
使用Vue.extend
和$mount
:
// https://css-tricks.com/creating-vue-js-component-instances-programmatically/
import Button from 'Button.vue'
import Vue from 'vue'
var ComponentClass = Vue.extend(Button)
var instance = new ComponentClass({
propsData: { type: 'primary' }
})
instance.$mount() // pass nothing
this.$refs.container.appendChild(instance.$el)