亚洲国产日韩欧美一区二区三区,精品亚洲国产成人av在线,国产99视频精品免视看7,99国产精品久久久久久久成人热,欧美日韩亚洲国产综合乱

Vuex sort in getters but prompts undefind
漂亮男人
漂亮男人 2017-06-15 09:23:40
0
1
1025

Use Vuex for data processing
But when loading data, I need to sort it. My approach is
In Getter

curProductLists: state => state.products.sort(true)

But when opening the page, an error message appears:

[Vue warn]: Error in render function: "TypeError: Cannot read property 'sort' of undefined"

found in

When you click on the menu and go to the page, the page data comes out. When F5 is refreshed, an error will be reported. I think this is because the data is sorted before it is loaded into the data. Is there any solution to this problem?

漂亮男人
漂亮男人

reply all(1)
黃舟

Put the sorting operation into mutation, load data in action (asynchronous operation), and commit mutation in its callback

Refer to the sample code in the shopping cart in the official documentation

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template