9433cfb9创建于 2025年12月31日历史提交
<template>
  <view>
    <MyPickerView ref='pickerViewRef' v-if='visible'></MyPickerView>
    <button class="btn_toggle" @click="toggle">btn</button>
  </view>
</template>

<script>
  import MyPickerView from './picker-view.uvue'
  export default {
    data() {
      return {
        visible: false,
        pickerViewRef: null
      }
    },
    components: {
      MyPickerView
    },
    methods: {
      setValue() {
        const instance = this.$refs['pickerViewRef']
        if (instance != null) {
          (instance as ComponentPublicInstance).$callMethod('setValue')
        }
      },
      toggle() {
        this.visible = !this.visible
        if (this.visible) {
          nextTick(() => {
            this.setValue()
          })
        }
      }
    }
  }
</script>

<style>

</style>