1.第一种使用script标签html>
{{test}} look test component!
//全局注册组件
Vue.component('test-component',{
template: '#testComponent',
data(){ return{
test:"hello"
}
}
}) new Vue({
el: '#app'
})
注意:使用
浏览器在解析HTML文档时会忽略
2.第二种使用template标签html>
look test component!
Vue.component('test-component',{
template: '#testComponent'
}) new Vue({
el: '#app'
})