Commit e548ccd2 authored by 李昊晨's avatar 李昊晨

📝 修改showmodal默认颜色,增加组件递归文档

parent f1a978d3
......@@ -3082,6 +3082,12 @@ module.exports = {
path: '/framework/custom-component/observer.md',
collapsable: true,
sidebarDepth: 1
},
{
title: '递归组件',
path: '/framework/custom-component/recursive-component.md',
collapsable: true,
sidebarDepth: 1
}
]
},
......
......@@ -12,9 +12,9 @@
| content | string | | 是 | 提示的内容 |
| showCancel | boolean | true | 否 | 是否显示取消按钮 |
| cancelText | string | '取消' | 否 | 取消按钮的文字,最多 4 个字符 |
| cancelColor | string | #000000 | 否 | 取消按钮的文字颜色 |
| cancelColor | string | #0086FF | 否 | 取消按钮的文字颜色 |
| confirmText | string | '确定' | 否 | 确认按钮的文字,最多 4 个字符 |
| confirmColor | string | #576B95 | 否 | 确认按钮的文字颜色 |
| confirmColor | string | #FFFFFF | 否 | 确认按钮的文字颜色 |
| success | function | | 否 | 接口调用成功的回调函数 |
| fail | function | | 否 | 接口调用失败的回调函数 |
| complete | function | | 否 | 接口调用结束的回调函数(调用成功、失败都会执行) |
......
# 递归组件
自定义组件只需要简单配置即可递归使用。
在自定义组件的 `.json` 配置文件中,添加 `name` 字段,并指定名称,则可以在自定义组件中使用此字段的值作为组件名。如:
_my-layer.json_
```json{2}
{
"name": "my-layer",
"component": true
}
```
_my-layer.js_
```js
Component({
properties: {
depth: {
type: Number,
value: 1
}
}
})
```
_my-layer.qxml_
```xml
<view class='my-layer'>
this is layer {{ depth }}
<my-layer qa:if='{{ depth > 1 }}' depth='{{ depth - 1 }}'></my-layer>
</view>
```
## 全局组件
`app.json` 中配置配置的组件,也可以作为递归组件使用。如:
_app.json_
```json
{
"usingComponents": {
"global-layer": "./components/global-layer/global-layer"
}
}
```
_global-layer.js_
```js
Component({
properties: {
depth: {
type: Number,
value: 1
}
}
})
```
_global-layer.qxml_
```xml
<view class='global-layer'>
this is layer {{ depth }}
<global-layer qa:if='{{ depth > 1 }}' depth='{{ depth - 1 }}'></global-layer>
</view>
```
以上是两种组件的使用使用如:
_page.qxml_
```xml
<view>
<my-layer depth='{{ 3 }}'></my-layer>
<global-layer depth='{{ 3 }}'></global-layer>
</view>
```
::: warning 注意
使用递归组件时,需要注意使用条件控制递归,否则可能会出现无限循环,出现 “max stack size exceeded” 的错误。
:::
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment