一、共同属性(所有wxml标签都支持的属性)
1.id(string类型) 组件的唯一标识,整个页面中唯一
2.class(string类型) 组件的样式类
3.style(string类型) 内联样式
4.hidden(bool值) 组件是否显示
5.data-* 自定义属性 组件触发事件的时候传递给事件处理函数
6.bind/catch 组件的事件
二、模板(template)
1.定义模板
<template name="tem1">
<view>
{{index}}--{{name}}
</view>
</template>2.调用模板(index和name是传入data中对象的属性)
tnt只能是一个对象的类型
<template is="tem1" data="{{...tnt}}"></template>下边是tnt在data中的定义
tnt:{
name:"lihua",
index:0,
},三、引用
1.第一种引用方式:import可以引用对应文件中定义的template;注意的是import不具有递归性,也就是import对应文件的时候,当对应文件也有import引用其他文件的时候,当前文件不会引用对应文件引用的文件(相当于a引入b,b引入c,a不能调用c中的template)
<import src="./user"></import>
<template is="haihaihai"></template>其中user文件的内容为如下代码
<template name="haihaihai">我出来了</template>2.第二种引用方式include可以把目标文件除template和wxs标签外的整个代码引入,相当于是拷贝到include所在的位置
版权声明:本文为m0_72694993原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。