Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
241 views
in Technique[技术] by (71.8m points)

问个vue组件问题

var child = {template: '<div>this is child component </div>'};


var child = Vue.extend({template: '<div>this is child component </div>'});
区别

求详细解答


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

区别是,extend 设置的没有id('my-component')

// 设
var child = Vue.extend({/*略*/});
Vue.component('my-component',child);
// 等价与
Vue.component('my-component',{/*略*/});
// 设 
Vue.component('my-component',{/*略*/});
// 则下面两个 child 等价
var child = Vue.extend({/*略*/});
var child = Vue.componet('my-component')

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...