mirror of
https://gitee.com/vant-contrib/vant-weapp.git
synced 2025-04-05 19:41:45 +08:00
docs(Accordion): add method document
This commit is contained in:
parent
2eb13caa27
commit
6e572ff313
@ -6,29 +6,28 @@ Page({
|
||||
active1: [0],
|
||||
active2: 0,
|
||||
active3: [],
|
||||
active4: [],
|
||||
title1: '有赞微商城',
|
||||
title2: '有赞零售',
|
||||
title3: '有赞美业',
|
||||
content1: '提供多样店铺模板,快速搭建网上商城',
|
||||
content2:
|
||||
'网店吸粉获客、会员分层营销、一机多种收款,告别经营低效和客户流失',
|
||||
content3: '线上拓客,随时预约,贴心顺手的开单收银'
|
||||
content3: '线上拓客,随时预约,贴心顺手的开单收银',
|
||||
},
|
||||
|
||||
onChange(event) {
|
||||
const { key } = event.currentTarget.dataset;
|
||||
this.setData({
|
||||
[key]: event.detail
|
||||
[key]: event.detail,
|
||||
});
|
||||
},
|
||||
|
||||
onOpen(event) {
|
||||
const openItem = event.detail;
|
||||
Toast(`当前展开的面板的name: ${openItem}`);
|
||||
Toast(`展开: ${event.detail}`);
|
||||
},
|
||||
|
||||
onClose(event) {
|
||||
const closeItem = event.detail;
|
||||
Toast(`当前关闭的面板的name: ${closeItem}`);
|
||||
}
|
||||
Toast(`关闭: ${event.detail}`);
|
||||
},
|
||||
});
|
||||
|
@ -14,8 +14,8 @@
|
||||
</van-collapse>
|
||||
</demo-block>
|
||||
|
||||
<demo-block title="监听面板打开关闭事件">
|
||||
<van-collapse value="{{ active2 }}" data-key="active2" accordion bind:change="onChange" bind:open="onOpen" bind:close="onClose">
|
||||
<demo-block title="事件监听">
|
||||
<van-collapse value="{{ active3 }}" data-key="active3" bind:change="onChange" bind:open="onOpen" bind:close="onClose">
|
||||
<van-collapse-item title="{{ title1 }}">{{ content1 }}</van-collapse-item>
|
||||
<van-collapse-item title="{{ title2 }}">{{ content2 }}</van-collapse-item>
|
||||
<van-collapse-item title="{{ title3 }}">{{ content3 }}</van-collapse-item>
|
||||
@ -23,7 +23,7 @@
|
||||
</demo-block>
|
||||
|
||||
<demo-block title="自定义标题内容">
|
||||
<van-collapse value="{{ active3 }}" data-key="active3" bind:change="onChange">
|
||||
<van-collapse value="{{ active4 }}" data-key="active4" bind:change="onChange">
|
||||
<van-collapse-item>
|
||||
<view slot="title">
|
||||
{{ title1 }}
|
||||
|
@ -49,7 +49,7 @@ Page({
|
||||
通过`accordion`可以设置为手风琴模式,最多展开一个面板,此时`activeName`为字符串格式
|
||||
|
||||
```html
|
||||
<van-collapse value="{{ activeName }}" bind:change="onChange" accordion>
|
||||
<van-collapse accordion value="{{ activeName }}" bind:change="onChange">
|
||||
<van-collapse-item title="有赞微商城" name="1">
|
||||
提供多样店铺模板,快速搭建网上商城
|
||||
</van-collapse-item>
|
||||
@ -77,7 +77,7 @@ Page({
|
||||
|
||||
### 事件监听
|
||||
|
||||
`van-collapse` 提供了 `change`, `open` 和 `close` 事件。`change` 事件在面板切换时触发。`open` 事件在面板展开时触发。`close` 事件在面板关闭时触发。
|
||||
`van-collapse` 提供了 `change`, `open` 和 `close` 事件。`change` 事件在面板切换时触发,`open` 事件在面板展开时触发,`close` 事件在面板关闭时触发。
|
||||
|
||||
```html
|
||||
<van-collapse
|
||||
@ -98,6 +98,25 @@ Page({
|
||||
</van-collapse>
|
||||
```
|
||||
|
||||
```javascript
|
||||
Page({
|
||||
data: {
|
||||
activeNames: ['1'],
|
||||
},
|
||||
onChange(event) {
|
||||
this.setData({
|
||||
activeNames: event.detail,
|
||||
});
|
||||
},
|
||||
onOpen(event) {
|
||||
Toast(`展开: ${event.detail}`);
|
||||
},
|
||||
onClose(event) {
|
||||
Toast(`关闭: ${event.detail}`);
|
||||
},
|
||||
});
|
||||
```
|
||||
|
||||
### 自定义标题内容
|
||||
|
||||
```html
|
||||
|
@ -1,9 +1,5 @@
|
||||
# Divider 分割线
|
||||
|
||||
### 介绍
|
||||
|
||||
分割线
|
||||
|
||||
### 引入
|
||||
|
||||
在`app.json`或`index.json`中引入组件,默认为`ES6`版本,`ES5`引入方式参见[快速上手](#/quickstart)
|
||||
|
Loading…
x
Reference in New Issue
Block a user