LocalStorage storage data problem

the code is as follows:

    [SAVE_COLLECT](state,collectId){
        let collectArr = state.collectList.push(collectId);
        console.log(collectArr)
        //localStorage
        setStore("collectList",collectArr);
        console.log(window.localStorage)
    },

the value collectId passed in is the product id,. The purpose is to store the product id in localStorage,
every time you click on the product
question: when console.log (collectArr) clicks on the first product, it outputs 1 instead of an array containing the product id

.
Storage{collectList: "1", loglevel:webpack-dev-server: "WARN", prolist: "{"productId":22643,"title":"","cover":"httrice":0,"currentPrice":873,"channel":"","tab":""}", userInfo: "{"phone":"123456","code":"1234"}", length: 4}
Feb.25,2022

this has nothing to do with localstorage .
let collectArr = state.collectList.push (collectId); / / push the operation returns length of the array, so the value at this time is 1
should be changed to

.
state.collectList.push(collectId);
let collectArr = state.collectList;
localstorage.setItem('collectList',JSON.stringify(collectArr));
Menu