“`
})
var mycomponent = Vue.extend({
props: [‘title’,’content’],
template: ‘
{{title}}
{{content}}
‘,})
Vue.component('my-component',mycomponent);
var vm = new Vue({
el: "#app",
});
“`
本文介绍了一个使用Vue.js创建自定义组件的基本示例。通过定义props接收外部传入的数据,并在模板中显示这些数据。此示例展示了如何扩展Vue的基础功能以实现复用性和模块化。
18万+

被折叠的 条评论
为什么被折叠?



