assembly components defined vue

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

  1. Custom components require the use of components option. components is an object, the object's properties relevant component configuration information.
  2. Components which should at least have the template properties or render method.
  3. When used, the name of the component can be used as a label.
  4. Note: ⬇⬇ ============================================== ====== ⬇⬇
  5. 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.
  6. Examples of data among the components, the outside thereof is not shared.
  7. Data (data) defined within the assembly
    1. If a function must
    2. The function must have a return value
    3. If an object must return value
  8. Note: ⬆⬆ ============================================== ====== ⬆⬆

3. basic code shows:

/--------------------------html---------------------------------------/

<zujian></zujian>

/--------------------------js------------------------------------------/
new Vue({
	el:"#root",
	data:{
	... ...
	},
	components:{     //可以看到 components 是复数形式,说明我们可以在这里面定义多个组件
	zujian:{         //定义了一个名字为 zujian 的组件  //它是一个对象形式
		template:`   //指定一个模板
			<div>定义了一个组件,名字为 zujian </div>
		`
		}
	}
})
Published 63 original articles · won praise 6 · views 1231

Guess you like

Origin blog.csdn.net/qq_44163269/article/details/105063803