what if mutations uses this.$set to update state object data directly in a separate js file and will report an error this.$set is not a function
?
data in state
articleList: [
{
userinfo: {image: "static/img/3.jpeg", nickname: "eee", text: "", time: ""},
content: {href: "2222222", text: "test", create_time: "", updata_time: ""},
pic: [{path: "static/img/0.jpg"}, {path: "static/img/0.jpg"}, {path: "static/img/0.jpg"}],
likebar: {hot: 555, status: false, comments: 666},
isFollow: true
}
]
component triggers action
this.$store.dispatch ("getLists")
action.js
getLists (val) {
api.articleList().then((res) => {
val.commit("updateList", res)
})
}
mutations.js
updateList (state, data) {
this.$set(this.state.articleList, 0, data) //
this.state.articleList = data //
}