Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

123456789101112131415161718192021222324252627282930313233
  1. // stores/counter.js
  2. import {
  3. defineStore
  4. } from 'pinia';
  5. import {
  6. ref
  7. } from 'vue'
  8. //getters 其实就是 store 的计算属性集合,而且 getter 不能是异步函数
  9. //$reset() 重置
  10. //state的改变交给action去处理
  11. export const useCounterStore = defineStore('counter', () => {
  12. const screenWidth = ref(0); //屏幕宽度
  13. const screenHeight = ref(0); //屏幕高度
  14. const systemInfo = ref({})
  15. //获取系统信息
  16. uni.getSystemInfo({
  17. success(res) {
  18. //客户端平台 platform
  19. //版本 version
  20. systemInfo.value = res
  21. //屏幕宽度 screenWidth
  22. screenWidth.value = res.screenWidth
  23. //屏幕高度 screenHeight
  24. screenHeight.value = res.screenHeight
  25. }
  26. })
  27. return {
  28. systemInfo
  29. }
  30. });