新建目录→新建组件vue
编辑器会自动生成 组件的 wxml wxss js json 文件json
其中JS 文件中的结构和页面的不一样小程序
组件 json 文件中 须要开启组件的开关 告诉程序这是组件bash
{ "component": true}
复制代码
{
"usingComponents": { "component-tag-name": "path/to/the/custom/component" }
}
复制代码
<component-tag-name></component-tag-name>
复制代码
created 组件实例化,但节点树还未导入,所以这时不能用setDataxss
attached 节点树完成,能够用setData渲染节点,但没法操做节点编辑器
ready 组件布局完成,这时能够获取节点信息,也能够操做节点布局
moved 组件实例被移动到树的另外一个位置spa
detached 组件实例从节点树中移除code