// stores/counter.js import { defineStore } from 'pinia'; import { ref } from 'vue' //getters 其实就是 store 的计算属性集合,而且 getter 不能是异步函数 //$reset() 重置 //state的改变交给action去处理 export const useCounterStore = defineStore('counter', () => { const screenWidth = ref(0); //屏幕宽度 const screenHeight = ref(0); //屏幕高度 const systemInfo = ref({}) //获取系统信息 uni.getSystemInfo({ success(res) { //客户端平台 platform //版本 version systemInfo.value = res //屏幕宽度 screenWidth screenWidth.value = res.screenWidth //屏幕高度 screenHeight screenHeight.value = res.screenHeight } }) return { systemInfo } });