hjyd的手机端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

33 lines
862 B

2 years ago
  1. <template>
  2. <div class="bg">
  3. <span>当前数值{{ countComputed }}</span>
  4. <br />
  5. <span>双倍数值{{ doubleCount }}</span>
  6. <br />
  7. <button type="primary" size="default" @click="countStore.countAdd">
  8. +1
  9. </button>
  10. <button type="primary" size="default" @click="countStore.countReduce">
  11. -1
  12. </button>
  13. </div>
  14. </template>
  15. <script setup>
  16. import { computed, onMounted } from 'vue'
  17. import { get15DaysWeatherByArea } from '@/api'
  18. import { useCountStore } from '@/store'
  19. import { storeToRefs } from 'pinia'
  20. const countStore = useCountStore()
  21. // 通过计算属性
  22. const countComputed = computed(() => countStore.count)
  23. // 通过 storeToRefs api 结构
  24. const { doubleCount } = storeToRefs(countStore)
  25. onMounted(() => {
  26. get15DaysWeatherByArea()
  27. })
  28. </script>
  29. <style scoped lang="scss">
  30. .bg {
  31. background: $bg-color;
  32. }
  33. </style>