k***@gmail.com
k***@gmail.com
  • 发布:2019-10-15 18:14
  • 更新:2020-03-24 10:44
  • 阅读:837

【报Bug】picker-view与PopUp共用时, picker-view的value无效, PopUp关闭再打开后, 都选中了第一项

分类:uni-app
2019-10-15 18:14 负责人:无 分享
已邀请:
2***@qq.com

2***@qq.com

我也发现了 一样的问题 单个 picker-view-column 初始化 value 是有效的
多个 picker-view-column 第一次一直无效 要滚动出发 @change 才能更新 value 的值

下面是代码

<!--底部省市区三级联动 start-->  
        <view class="dialog-bottom-view" :class="[showPickerStatus?'dialog-bottom-show':'']">  
            <view class="shop-bottom-title-view">  
                <image style="width: 36upx; height: 36upx; align-self: center; margin-left: 40upx;" src="../../static/icon/icon-down-arrows.png"  
                 @tap="hidePickerDialog"></image>  
                <view class="shop-bottom-title-btn" style="margin-right: 40upx;" @tap="confirmAddressValue">确认</view>  
            </view>  
            <picker-view indicator-style="height:50px" style="margin-top: 10upx" class="shop-bttom-address-view" :value="value"  
             @change="columnPicker">  
                <picker-view-column>  
                    <view class="flex_row_c_c" v-for="(item,index) in proviceArr" :key="index">{{item}}</view>  
                </picker-view-column>  
                <picker-view-column>  
                    <view class="flex_row_c_c" v-for="(item,index) in cityArr" :key="index">{{item}}</view>  
                </picker-view-column>  
                <picker-view-column>  
                    <view class="flex_row_c_c" v-for="(item,index) in districtArr" :key="index">{{item}}</view>  
                </picker-view-column>  
            </picker-view>  
        </view>  
        <view class="dialog-mask" :class="[showPickerStatus?'dialog-mask-show':'']" @tap.stop="hidePickerDialog"></view>  
        <!--底部省市区三级联动 end-->  
onLoad(params){  
this.addressEntity = JSON.parse(decodeURIComponent(params.addressJson))  
            var addressList = this.addressEntity.address.split("\n")  
            this.address = addressList[1]  
            this.addressTxt[0] = addressList[0].split(" ")[0]  
            this.addressTxt[1] = addressList[0].split(" ")[1]  
            this.addressTxt[2] = addressList[0].split(" ")[2]  

            //初始化省市区三级联动数据  
            this.proviceArr = this.toArr(cityData)  
            let provIndex = this.proviceArr.indexOf(this.addressTxt[0])  
            this.cityArr = this.toArr(cityData[provIndex].Citys)  
            let cityIndex = this.cityArr.indexOf(this.addressTxt[1])  
            this.districtArr = this.toArr(cityData[provIndex].Citys[cityIndex].Areas)  
            let areaIndex = this.districtArr.indexOf(this.addressTxt[2])  

            this.value = [provIndex,cityIndex, areaIndex]  

            console.log("选择下标:" + this.value)  
}

数据传输没问题,代码也没什么问题 除了第一次进入页面 无法定位的默认 选项 其他都OK

拾荒

拾荒 - 可以不说话吗?

我是先把上次的数据记录下,然后用 this.$forceUpdate(); 重新渲染,然后再把值附上,就没有问题了

该问题目前已经被锁定, 无法添加新回复