在线观看不卡亚洲电影_亚洲妓女99综合网_91青青青亚洲娱乐在线观看_日韩无码高清综合久久

鍍金池/ 問答/HTML/ 使用mint-ui的picker出現(xiàn)的bug

使用mint-ui的picker出現(xiàn)的bug

在使用 picker 中,點(diǎn)擊選擇框彈起來,然后點(diǎn)擊確定按鈕調(diào)用 getValues() 獲取到當(dāng)前的選中的值,這時(shí)候我再次點(diǎn)擊選擇選擇按鈕,選擇框彈起來,這時(shí)候再點(diǎn)擊確定默認(rèn)選擇當(dāng)前被選中的,發(fā)現(xiàn) getValues() 獲取的值是undefind;(兩次選擇相同的內(nèi)容時(shí),第二次的getValues()取到的值是undefind)
因?yàn)槲业捻撁嬷杏行枰芏鄍icker選擇框,所以我是只初始化了一個(gè)picker,然后根據(jù)不同的事件來改變slots里的values的值,這樣想著會有利于性能;
clipboard.png

不知道大家有沒有遇到這種坑,找了半天還是不知道怎么解決,謝謝大家了!
data數(shù)據(jù)中的picker數(shù)據(jù)如下:
data(){
return{
popupVisible:false,//picker組件顯示和關(guān)閉
slots: [{defaultIndex:0}],//picker選擇框數(shù)據(jù)
}
}
picker組件代碼如下:

    <mt-popup v-model="popupVisible" position="bottom">
        <div class="picker-toolbar">  
            <span class="mint-datetime-cancel" @click="cancle">取消</span>  
            <span class="mint-datetime-confirm" @click="select">確定</span>  
        </div>  
        <mt-picker ref='pickerObj' :slots="slots" valueKey="name"></mt-picker>
    </mt-popup>

激活picker方法如下:

    career(){//職業(yè)類型選擇框
            this.popupVisible=true;//激活picker組件
            this.currentPicker='careerName';//當(dāng)前picker內(nèi)容變量
            this.currentPickerId='careerNameId';//當(dāng)前picker內(nèi)容id變量
            this.currentShow='isCareer';//
            this.slots=[{
                  defaultIndex:0,
                  flex: 1,
                  values: this.$utils.careerStyle,//職業(yè)類型
                  className: 'slot1',
                  textAlign: 'center'
            }];
        }

picker上select(點(diǎn)擊確定)方法如下:

    select(){
            var pickerVal=this.$refs.pickerObj.getValues();
            console.log(this.$refs.pickerObj.getValues());
            this.popupVisible=false;
        }
回答
編輯回答
遺莣

<mt-picker :slots="slots" @change="onValuesChange"></mt-picker>這部分用@change事件,

//用istemp保存選好的值
onSexChange(picker, values) {
        this.isTemp = values[0];
 },

然后

select(){//獲得這個(gè)值
    console.log(this.istemp);
}
2017年10月6日 04:25