1234567891011121314151617181920212223 |
- import {defineStore} from 'pinia';
- export const useCountStore = defineStore('count1',{
- // 1.state 相当于 data 数组的存储
- state() {
- return {
- num: 666
- }
- },
- // 2.getters 相当于 computed 计算属性
- getters:{
- bigNum:(state:any)=>{
- return state.num * 5;;
- }
- },
- // 3.actions 相当于 methods 方法
- actions:{
- addThing(val:number) {
- this.num += val;
- }
- }
- });
|