Andy2u
Andy2u
  • 发布:2024-12-05 09:25
  • 更新:2025-04-10 15:08
  • 阅读:94

[HBuilderX 4.36 ] 鸿蒙系统 picker组件的mode="multiSelector",直接闪退

分类:鸿蒙Next

昨天升级版本HBuilderX 4.36版本, 鸿蒙系统 picker组件的mode="multiSelector",直接闪退 其他系统都正常显示。
之前用的版本是HBuilderX 4.26版本,鸿蒙系统能正常显示,只是不能联动
代码如下:

<template>  
  <view class="pca-picker-cc">  
    <picker mode="multiSelector" @cancel="pickerClose()" @columnchange="bindMultiPickerColumnChange" @change="change" :value="multiIndexArr" :range="multiArray">  
      <slot></slot>  
    </picker>  
  </view>  
</template>  

<script>  
let _self;  
export default {  
  name: "pca-picker-cc",  
  // 此处定义传入的数据  
  props: {  
    addressList: {  
      type: Array,  
      default: []  
    },  
    resultDTO: {  
        type: Array,  
        default: []  
    },  
    isDefault:{ // 是否展示默认提示语  
      type: Boolean,  
      default: true  
    }  
  },  
  computed: {  
    multiIndexArr(){  
      return [this.provinceIndex, this.cityIndex, this.countyIndex];  
    },  
    province() {  
      return this.provinceList[this.provinceIndex] || {};  
    },  
    provinceList() {  
      return this.data;  
    },  
    provinceNameList() {  
      return this.provinceList.map((item, index) => item.text || '');  
    },  
    city() {  
      return this.cityList[this.cityIndex] || {};  
    },  
    cityList() {  
      return this.province.children || [];  
    },  
    cityNameList() {  
      return this.cityList.map((item, index) => item.text || '');  
    },  
    county() {  
      return this.countyList[this.countyIndex] || {};  
    },  
    countyList() {  
      return this.city.children || [];  
    },  
    countyNameList() {  
      return this.countyList.map((item, index) => item.text || '');  
    },  
    multiArray() {  
      return [this.provinceNameList, this.cityNameList, this.countyNameList];  
    },  
    addressResultObj() {  
      return {province: this.province, city: this.city, county: this.county};  
    },  
    addressResultList(){  
      return Object.values(this.addressResultObj).map((item, index) => item.text || '');  
    }  
  },  
  data() {  
    return {  
      data: [],  
     // resultDTO:[],  
      provinceIndex: 0,  
      cityIndex: 0,  
      countyIndex: 0,  
      keys: ['province', 'city', 'county'],  
      upDown:false,  
    };  
  },  
  //在实例创建完成后被立即调用。  
  mounted() {  
    _self = this;  
   _self.data = this.resultDTO;  
    if(_self.isDefault){  
      _self.init();  
    }  
  },  
  methods: {  
  // 获取数据  
  // async loadData() {  
    // const result = await this.$axios(this.$baseUrl.schooSelectAllRegion);  
    // this.resultDTO = fn.FuncUnzip(result.data.obj);  
    // console.log("resultDTO1", this.resultDTO)  
    // _self.data = this.resultDTO;  
    // console.log("_self.data:",this.resultDTO)  
    // _self.init();  
  // },  

    init() {  
      if (this.addressList.length === 3) {  
        let key, index;  
        for (let i in this.keys) {  
          key = this.keys[i];  
          index = this[`${key}NameList`].indexOf(this.addressList[i]);  
          if (index <= -1) {  
            index = 0;  
          }  
          this.$data[`${key}Index`] = index;  
        }  
        this.change();  
      }  
    },  
    bindMultiPickerColumnChange: function (e) {  
      let index = e.detail.column;  
      let key = this.keys[index];  
      this.$data[`${key}Index`] = e.detail.value;  
      while (index < this.keys.length) {  
        index++;  
        key = this.keys[index];  
        this.$data[`${key}Index`] = 0;  
      }  
    },  
    change(e){  
      // console.log(e)  
      this.$emit('update:addressList', this.addressResultList);  
      this.$emit('getAddressResultObj', this.addressResultObj);  
      this.$emit('pickerClose', this.upDown);  
    },  
    pickerClose(){  
        this.$emit('pickerClose', this.upDown);  
    }  
  }  
}  
</script>  

<style lang="scss">  

</style>  
2024-12-05 09:25 负责人:无 分享
已邀请:
AresGG

AresGG

有解决吗,大佬

要回复问题请先登录注册