BtnClickMe.vue 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. <template>
  2. <Transition name="fade-in-out">
  3. <button
  4. v-show="isShow"
  5. class="btn-click-me"
  6. >
  7. <div
  8. v-if="props.text"
  9. class="text animation-show-hide-half"
  10. >
  11. {{ props.text }}
  12. </div>
  13. <img
  14. class=""
  15. :src="require(`@/assets/images/icon-click-tip.png`)"
  16. alt=""
  17. draggable="false"
  18. >
  19. </button>
  20. </Transition>
  21. </template>
  22. <script setup>
  23. import useSizeAdapt from "@/useFunctions/useSizeAdapt"
  24. import { ref, computed, watch, onMounted, inject } from "vue"
  25. import { useRoute, useRouter } from "vue-router"
  26. import { useStore } from "vuex"
  27. const route = useRoute()
  28. const router = useRouter()
  29. const store = useStore()
  30. const $env = inject('$env')
  31. const {
  32. windowSizeInCssForRef,
  33. windowSizeWhenDesignForRef,
  34. } = useSizeAdapt()
  35. const props = defineProps({
  36. color: {
  37. type: String,
  38. default: 'white', // 'green'
  39. },
  40. text: {
  41. type: String,
  42. default: '',
  43. },
  44. isShow: {
  45. type: Boolean,
  46. default: true,
  47. }
  48. })
  49. const color = computed(() => {
  50. if (props.color === 'white') {
  51. return '#fff'
  52. } else if (props.color === 'green') {
  53. return '#7B916B'
  54. } else {
  55. return props.color
  56. }
  57. })
  58. const isShow = computed(() => {
  59. return props.isShow
  60. })
  61. </script>
  62. <style lang="less" scoped>
  63. .btn-click-me{
  64. display: flex;
  65. align-items: center;
  66. >.text{
  67. color: v-bind('color');
  68. margin-right: calc(10 / v-bind('windowSizeWhenDesignForRef') * v-bind('windowSizeInCssForRef'));
  69. font-family: KaiTi, KaiTi;
  70. font-weight: 400;
  71. font-size: calc(20 / v-bind('windowSizeWhenDesignForRef') * v-bind('windowSizeInCssForRef'));
  72. }
  73. >img{
  74. width: calc(30 / v-bind('windowSizeWhenDesignForRef') * v-bind('windowSizeInCssForRef'));
  75. height: calc(30 / v-bind('windowSizeWhenDesignForRef') * v-bind('windowSizeInCssForRef'));
  76. }
  77. .animation-show-hide-half {
  78. animation: show-hide 1.5s infinite;
  79. }
  80. }
  81. @keyframes show-hide {
  82. 0% {
  83. opacity: 0.4;
  84. }
  85. 50% {
  86. opacity: 1;
  87. }
  88. 100% {
  89. opacity: 0.4;
  90. }
  91. }
  92. </style>