更新记录
1.0.0(2024-05-20) 下载此版本
1.0.0(2024-05-20)
支持双向绑定的picker组件,该组件是基于picker进行二次开发的
注:该版本是基于vue2开发的,所以只支持vue2,后续会升级vue3版本
功能
- 支持双向绑定
- 支持change事件
- 支持对字典做映射处理
示例代码
<template>
<view class="content">
<view class="demo">
<view class="title">性别:</view>
<pro-reactive-picker :map="{name:'name',value:'value'}"
range-key="name"
:style="{width:'100%'}"
:dict-data="dictData"
v-model="pickerValue"
@change="handlePickerChange"
></pro-reactive-picker>
</view>
<view class="demo">
<view class="title">兴趣爱好:</view>
<pro-reactive-picker :map="{name:'name',value:'value'}"
range-key="name"
:style="{width:'100%'}"
:dict-data="hobbyData"
v-model="hobbyName"
@change="handlePickerChange"
></pro-reactive-picker>
</view>
</view>
</template>
<script>
export default {
data() {
return {
dictData: [
{
name:'男',
value:0
},
{
name:'女',
value:1
},
],
hobbyData: [
{
name:'打篮球',
value:0
},
{
name:'游泳',
value:1
},
],
pickerValue:'',
hobbyName:''
}
},
onLoad() {
},
methods: {
handlePickerChange({nameStr,checkedOptions}){
console.log('selected value',nameStr,checkedOptions)
uni.showToast({
icon:'none',
duration:5000,
title:nameStr
})
}
}
}
</script>
<style>
.content {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
}
.demo {
width:50%;
display: flex;
justify-content: center;
}
.title {
width: 180rpx;
font-size: 32rpx;
color: #8f8f94;
}
</style>
平台兼容性
Vue2 | Vue3 |
---|---|
√ | × |
App | 快应用 | 微信小程序 | 支付宝小程序 | 百度小程序 | 字节小程序 | QQ小程序 |
---|---|---|---|---|---|---|
HBuilderX 3.6.17 app-vue app-nvue | √ | √ | √ | √ | √ | √ |
钉钉小程序 | 快手小程序 | 飞书小程序 | 京东小程序 |
---|---|---|---|
√ | √ | √ | √ |
H5-Safari | Android Browser | 微信浏览器(Android) | QQ浏览器(Android) | Chrome | IE | Edge | Firefox | PC-Safari |
---|---|---|---|---|---|---|---|---|
√ | √ | √ | √ | √ | √ | √ | √ | √ |
1.0.0(2024-05-20)
支持双向绑定的picker组件,该组件是基于picker进行二次开发的
注:该版本是基于vue2开发的,所以只支持vue2,后续会升级vue3版本
功能
- 支持双向绑定
- 支持change事件
- 支持对字典做映射处理
示例代码
<template>
<view class="content">
<view class="demo">
<view class="title">性别:</view>
<pro-reactive-picker :map="{name:'name',value:'value'}"
range-key="name"
:style="{width:'100%'}"
:dict-data="dictData"
v-model="pickerValue"
@change="handlePickerChange"
></pro-reactive-picker>
</view>
<view class="demo">
<view class="title">兴趣爱好:</view>
<pro-reactive-picker :map="{name:'name',value:'value'}"
range-key="name"
:style="{width:'100%'}"
:dict-data="hobbyData"
v-model="hobbyName"
@change="handlePickerChange"
></pro-reactive-picker>
</view>
</view>
</template>
<script>
export default {
data() {
return {
dictData: [
{
name:'男',
value:0
},
{
name:'女',
value:1
},
],
hobbyData: [
{
name:'打篮球',
value:0
},
{
name:'游泳',
value:1
},
],
pickerValue:'',
hobbyName:''
}
},
onLoad() {
},
methods: {
handlePickerChange({nameStr,checkedOptions}){
console.log('selected value',nameStr,checkedOptions)
uni.showToast({
icon:'none',
duration:5000,
title:nameStr
})
}
}
}
</script>
<style>
.content {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
}
.demo {
width:50%;
display: flex;
justify-content: center;
}
.title {
width: 180rpx;
font-size: 32rpx;
color: #8f8f94;
}
</style>