1. Basic information
Components is an extension of your html tags
Content component which is your template content
Assembly into the global component and the local component
- Component objects which are defined in the sub-assembly
2. How to define the (registered) Components
- Custom components require the use of components option. components is an object, the object's properties relevant component configuration information.
- Components which should at least have the template properties or render method.
- When used, the name of the component can be used as a label.
- Note: ⬇⬇ ============================================== ====== ⬇⬇
- When you use the component name among the hump naming when using the component, between lowercase and uppercase name it should be used - to split.
- Examples of data among the components, the outside thereof is not shared.
- Data (data) defined within the assembly
- If a function must
- The function must have a return value
- If an object must return value
- Note: ⬆⬆ ============================================== ====== ⬆⬆
3. basic code shows:
/--------------------------html---------------------------------------/
<zujian></zujian>
/--------------------------js------------------------------------------/
new Vue({
el:"#root",
data:{
... ...
},
components:{ //可以看到 components 是复数形式,说明我们可以在这里面定义多个组件
zujian:{ //定义了一个名字为 zujian 的组件 //它是一个对象形式
template:` //指定一个模板
<div>定义了一个组件,名字为 zujian </div>
`
}
}
})