This commit is contained in:
qimengjie
2018-12-12 20:43:54 +08:00
parent bd76a640ba
commit 6d6e4e07f5
5 changed files with 340 additions and 14 deletions

View File

@@ -1 +1,89 @@
Page({})
Page({
/**
* 页面的初始数据
*/
data: {
result: [],
steps: 3,
name: 'name',
subset: 'sonValue',
otherFields: ['id', 'city'],
originMultiArray: [
{
id: '01',
name: '1',
sonValue: [
{
id: '011',
name: '1.1',
sonValue: [
{
id: '0111',
name: '1.1.1',
},
{
id: '0112',
name: '1.1.2',
}
]
},
{
id: '012',
name: '1.2',
sonValue: [
{
id: '0121',
name: '1.2.1',
},
{
id: '0122',
name: '1.2.2',
}
]
}
]
},
{
id: '02',
name: '2',
sonValue: [
{
id: '021',
name: '2.1',
sonValue: [
{
id: '0211',
name: '2.1.1',
},
{
id: '0212',
name: '2.1.2'
}
]
},
{
id: '022',
name: '2.2',
sonValue: [
{
id: '0221',
name: '2.2.1'
},
{
id: '0222',
name: '2.2.2'
}
]
}
]
}
]
},
mutiPickerChange(e) {
console.log('多级联动结果:', e.detail)
this.setData({
result: e.detail.selectedArray
})
}
})

View File

@@ -1 +1,22 @@
<comp></comp>
<!-- 多级联动 -->
<!--
origin: 源数组,格式必须为数组和对象的集合,参考示例
steps: 多级联动的阶数默认为0
name: 多级联动展示数据的字段名称默认为name
subset: 多级联动的子节点的字段名称默认为subset
otherFields: 若需要额外返回其他字段的数据可以设置otherFields为数组参考示例
autoSelect: 初始化时自动选择每列第0项
bindchange: 回调函数,参考示例
-->
<comp
sourceData="{{originMultiArray}}"
steps="{{steps}}"
shownFieldName="{{name}}"
subsetFieldName="{{subset}}"
otherNeedFieldsName="{{otherFields}}"
autoSelect
bindchange="mutiPickerChange">
<view class="picker">
当前选择:<text wx:for="{{result}}" wx:key="index">{{item[name]}}</text>
</view>
</comp>

View File

@@ -14,7 +14,7 @@
"compileType": "miniprogram",
"libVersion": "2.2.3",
"appid": "",
"projectname": "miniprogram-demo",
"projectname": "miniprogram-picker",
"isGameTourist": false,
"condition": {
"search": {