更新时间:2019-09-09 14:07
自定义组件的使用和基础组件类似。
在页面 JSON 文件中指定使用的自定义组件。
// /pages/index/index.json
{
"usingComponents": {
"customer": "/components/customer/index"
}
}
在页面的 AXML 文件中使用自定义组件,与使用基础组件类似。
<!-- /pages/index/index.axml -->
<view>
<!-- 给自定义组件传递 属性name与属性age -->
<customer name="tom" age="{{23}}"/>
</view>
this.props
获取,参见 props。正确示例:
<!-- /pages/index/index.axml -->
<my-com />
错误示例:
<!-- /pages/index/index.axml -->
<include src="./template.axml" />
<!-- /pages/index/template.axml -->
<view>
<my-com />
</view>
// 在 /pages/index/index.json 中配置(不是 app.json )
{
"usingComponents":{
"your-custom-component":"mini-antui/es/list/index",
"your-custom-component2":"/components/card/index",
"your-custom-component3":"./result/index",
"your-custom-component4":"../result/index"
}
}
// 项目绝对路径以 / 开头,相对路径以 ./ 或者 ../ 开头
在文档使用中是否遇到以下问题
更多建议
匿名提交