Closed sikerxu closed 1 month ago
this.arr.length in store index , one time right, more time wrong
import { defineStore } from "pinia";
export const useMainStore = defineStore('main',{
state:()=>{ return { count:100, foo:'foo', arr:[1,2,3], } },
// 类似于组件的 computed,用来封装计算属性,有缓存的功能 getters:{
},
// 类似组件的 methods 封装业务逻辑,修改state actions:{ gai(num){ this.count+=num; this.foo=this.foo + num; this.arr.push(this.arr.length + num); // 有 BUG } } })
App.vue
click the button 3 times, result is [ 1, 2, 3, 8, 9, 10, 11, 12 ]
No response
Open a properly formatted markdown discussion in the help section and you will likely receive help 🙂
Reproduction
this.arr.length in store index , one time right, more time wrong
Steps to reproduce the bug
import { defineStore } from "pinia";
export const useMainStore = defineStore('main',{
state:()=>{ return { count:100, foo:'foo', arr:[1,2,3], } },
// 类似于组件的 computed,用来封装计算属性,有缓存的功能 getters:{
},
// 类似组件的 methods 封装业务逻辑,修改state actions:{ gai(num){ this.count+=num; this.foo=this.foo + num; this.arr.push(this.arr.length + num); // 有 BUG } } })
App.vue
Expected behavior
click the button 3 times, result is [ 1, 2, 3, 8, 9, 10, 11, 12 ]
Actual behavior
click the button 3 times, result is [ 1, 2, 3, 8, 9, 10, 11, 12 ]
Additional information
No response