index.vue 991 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. <template>
  2. <el-tooltip v-if="btn_Info" :content="btn_Info.textInfo" placement="top" :disabled="!isBubble || !btn_Info.textInfo">
  3. <slot />
  4. </el-tooltip>
  5. </template>
  6. <script setup>
  7. import { onMounted, ref, watch } from 'vue'
  8. import { useAppStore } from '~src/store'
  9. //参数
  10. const props = defineProps({
  11. keys: {
  12. type: String,
  13. default: '',
  14. },
  15. })
  16. const useAppState = useAppStore()
  17. //变量
  18. const btn_Info = ref(false)
  19. const btn_key = ref(props.keys)
  20. const isBubble = ref(useAppState.getBubble)
  21. //监听
  22. watch(() => [
  23. props.keys, useAppState.getBubble, useAppState.getButtons,
  24. ], ([keys, bubble, btns]) => {
  25. btn_key.value = keys
  26. isBubble.value = bubble
  27. btn_Info.value = getButtonsVal(keys)
  28. }, { deep: true })
  29. //渲染完成
  30. onMounted(()=> {
  31. if (props.keys) {
  32. btn_Info.value = getButtonsVal(props.keys)
  33. }
  34. })
  35. //获取气泡数据
  36. const getButtonsVal = (value) => {
  37. return useAppState.getButtonsVal(value)
  38. }
  39. </script>