1***@qq.com
1***@qq.com
  • 发布:2019-08-19 14:58
  • 更新:2025-06-20 16:16
  • 阅读:8031

unipopup+picker-view,这么低级的bug都有

分类:uni-app

app效果:

h5,微信小程序无此bug

代码如下
<template>
<view>
<view style="height: 100rpx;"></view>
{{JSON.stringify(value)}}
<button @click="openPopup">打开选择器</button>

    <uniPopup :show="false" ref="popup" type="bottom" >  
        <picker-view class="single-picker" indicator-style="height: 80rpx;" @change="changePicker" :value="value">  
            <picker-view-column>  
                <block v-for="(item,index) in list" :key="index">  
                    <view class="disease-item">{{item[labelKey]}}</view>  
                </block>  
                <!-- 匿名插槽,可用于 插入显示列表加载提示 -->  
                <slot></slot>  
            </picker-view-column>  
        </picker-view>  
    </uniPopup>  
</view>  

</template>

<script>
import uniPopup from '@/components/uni-popup/uni-popup.vue'
export default {
name: "getlocation",
components:{
uniPopup
},
data() {
return {
labelKey: "name",
list: [],
value: [0]
}
},
onLoad() {
this.getList();
},
methods: {
getList() {
for (var i = 0; i < 12; i++) {
this.list.push({
name: "" + i,
id: i
})
}
},
changePicker(e) {
console.log(e.detail.value)
this.value = e.detail.value;
//this.$emit("change",e.detail.value);
},
openPopup() {
this.$refs.popup.open();
},
changePopUp(obj) {
console.log(this.value)
}
}
}
</script>

<style lang="scss">
.single-picker{
height: 50vh;
}
</style>

0 关注 分享

要回复文章请先登录注册

1***@qq.com

1***@qq.com

我也遇到这个问题了,bug好多啊
2020-03-19 18:44
2***@qq.com

2***@qq.com

你有没有觉得自己写东西有问题呀?
2019-09-11 15:43
8***@qq.com

8***@qq.com

我也有这个问题,picker-view 不在视图显示时也会改变 index 触发 change 事件,直到所有列 index 都变成 0,比如有两列 [2, 3],第一次会变成 [0, 3],第二次变成 [0, 0],然后不变了
2019-09-11 09:55
1***@qq.com

1***@qq.com (作者)

回复 1***@qq.com :
我检查了几次,没发现问题。
2019-08-22 08:28
1***@qq.com

1***@qq.com

你有没有觉得自己写东西有问题呀?
2019-08-22 08:03