关于#vue.js#的问题:vue.js错:TypeError: this.collect.push is not

vue.js报错:
TypeError: this.collect.push is not

代码:

  • javascript import { defineStore } from 'pinia'html
import { stringifyQuery } from 'vue-router'


export const collectStore = defineStore('collect', {
    state:()=>({
            collect:[]
    }),
    actions:{
        addToCollect(collection){
            this.collect.push(collection)
        }
    },
    persist: true
    }
)

传入的参数collection

state.collection = Object.values(row) //将对象转为数组
addToCollect(state.collection)

你打印一下this.collect

vuex 不能你这么用