Vue 中声明组件的方法
1. 组件注册
组件可以使用 Vue.component(name, options)
方法注册。其中,name
是组件名称,options
是组件配置对象,包括 template、data、methods 等属性。
<code class="javascript">// 注册组件 Vue.component(\'my-component\', { template: \'<div>这是我的组件</div>\' });</code>
Vue 中声明组件的方法
1. 组件注册
组件可以使用 Vue.component(name, options)
方法注册。其中,name
是组件名称,options
是组件配置对象,包括 template、data、methods 等属性。
<code class="javascript">// 注册组件 Vue.component(\'my-component\', { template: \'<div>这是我的组件</div>\' });</code>
之前