adcold
adcold
  • 发布:2023-04-10 01:18
  • 更新:2023-04-10 14:52
  • 阅读:222

【报Bug】3.7.9.20230324 picker-view 动态设置mask-style不生效

分类:uni-app

产品分类: uniapp/App

PC开发环境操作系统: Mac

PC开发环境操作系统版本号: 12.6.1

HBuilderX类型: 正式

HBuilderX版本号: 3.7.9

手机系统: Android

手机系统版本号: Android 12

手机厂商: 三星

手机机型: s10

页面类型: vue

vue版本: vue2

打包方式: 云端

项目创建方式: HBuilderX

操作步骤:

设置mask-style,在进行动态更改或v-if控制显示不生效

预期结果:

可动态更换

实际结果:

无法动态更换

bug描述:

<picker-view indicator-class="city-picker"  
            v-if="mode==='s3' || mode==='s2' || mode==='s1' && maskStyle === false" class="n-flex-1" :indicator-style="mrIndicatorStyle"  
            :value="pickVal" @change="bindChange">  
            <picker-view-column>  
                <view class="n-flex-column n-align-center n-justify-center" :style="mrItemStyle"  
                    v-for="(item,index) in items.p||[]" :key="index">  
                    <text :class="['n-picker-item-text', 'n-lines-1', ''+textType, ''+textSize]"  
                        :style="textStyle">{{item[pl]}}</text>  
                </view>  
            </picker-view-column>  
            <picker-view-column v-if="mode==='s2' || mode==='s3'">  
                <view class="n-flex-column n-align-center n-justify-center" :style="mrItemStyle"  
                    v-for="(item,index) in items.c||[]" :key="index">  
                    <text :class="['n-picker-item-text', 'n-lines-1', ''+textType, ''+textSize]"  
                        :style="textStyle">{{item[cl]}}</text>  
                </view>  
            </picker-view-column>  
            <picker-view-column v-if="mode==='s3'">  
                <view class="n-flex-column n-align-center n-justify-center" :style="mrItemStyle"  
                    v-for="(item,index) in items.a||[]" :key="index">  
                    <text :class="['n-picker-item-text', 'n-lines-1', ''+textType, ''+textSize]"  
                        :style="textStyle">{{item[al]}}</text>  
                </view>  
            </picker-view-column>  
        </picker-view>  
        <picker-view indicator-class="city-picker" mask-style="background: #2c2c34;z-index: 0;"  
            v-if="mode==='s3' || mode==='s2' || mode==='s1' && maskStyle === true" class="n-flex-1" :indicator-style="mrIndicatorStyle"  
            :value="pickVal" @change="bindChange">  
            <picker-view-column>  
                <view class="n-flex-column n-align-center n-justify-center" :style="mrItemStyle"  
                    v-for="(item,index) in items.p||[]" :key="index">  
                    <text :class="['n-picker-item-text', 'n-lines-1', ''+textType, ''+textSize]"  
                        :style="textStyle">{{item[pl]}}</text>  
                </view>  
            </picker-view-column>  
            <picker-view-column v-if="mode==='s2' || mode==='s3'">  
                <view class="n-flex-column n-align-center n-justify-center" :style="mrItemStyle"  
                    v-for="(item,index) in items.c||[]" :key="index">  
                    <text :class="['n-picker-item-text', 'n-lines-1', ''+textType, ''+textSize]"  
                        :style="textStyle">{{item[cl]}}</text>  
                </view>  
            </picker-view-column>  
            <picker-view-column v-if="mode==='s3'">  
                <view class="n-flex-column n-align-center n-justify-center" :style="mrItemStyle"  
                    v-for="(item,index) in items.a||[]" :key="index">  
                    <text :class="['n-picker-item-text', 'n-lines-1', ''+textType, ''+textSize]"  
                        :style="textStyle">{{item[al]}}</text>  
                </view>  
            </picker-view-column>  
        </picker-view>  
<style lang="scss" scoped>  
    .n-picker {  
        &-box {  
            overflow: hidden;  
        }  

        &-item {  
            &-text {  
                text-align: center;  
            }  
        }  
    }  

    .city-picker {  
        border-top: 1rpx solid;  
        border-bottom: 1rpx solid;  
        border-image: linear-gradient(to right, #4253d8, #d533ba) 1;  
    }  

    .maskStyle {  
        background: #2c2c34;  
        z-index: 0;  
    }  
</style>

试过两种方案 一个是动态设置mask-style 一个是v-if设置 mask-style,始终都是设置的第一次的值再次更改不生效

2023-04-10 01:18 负责人:无 分享
已邀请:
DCloud_UNI_LXH

DCloud_UNI_LXH

picker-view 加上 key 值然后切换试试

  • adcold (作者)

    使用key解决

    2023-04-10 17:27

要回复问题请先登录注册