wrap-picker-view.uvue 804 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. <template>
  2. <view>
  3. <MyPickerView ref='pickerViewRef' v-if='visible'></MyPickerView>
  4. <button class="btn_toggle" @click="toggle">btn</button>
  5. </view>
  6. </template>
  7. <script>
  8. import MyPickerView from './picker-view.uvue'
  9. export default {
  10. data() {
  11. return {
  12. visible: false,
  13. pickerViewRef: null
  14. }
  15. },
  16. components: {
  17. MyPickerView
  18. },
  19. methods: {
  20. setValue() {
  21. const instance = this.$refs['pickerViewRef']
  22. if (instance != null) {
  23. (instance as ComponentPublicInstance).$callMethod('setValue')
  24. }
  25. },
  26. toggle() {
  27. this.visible = !this.visible
  28. if (this.visible) {
  29. nextTick(() => {
  30. this.setValue()
  31. })
  32. }
  33. }
  34. }
  35. }
  36. </script>
  37. <style>
  38. </style>