use merging two arrays in vue to switch routes and render repeatedly
sources of topics and their own ideas
related codes
the first step is to get the data in the background and submit it to Store using vuex to merge the original data
let data = [
{
name:"",
id:"123"
}
]
this.$store.commit ("setYyuedata", data);
the second step is to merge the two data and render to the front
export default new Vuex.Store ({
state: {
yuyuedata:[],
},
getters: {
getYuyuedata: state => state.yuyuedata,
},
mutations: {
//
setYyuedata(state, data){
state.yuyuedata = state.yuyuedata.concat(data);
}
}
})
part III, front end with new data
(1). Get state data
computed: {
...mapGetters([
"getYuyuedata"
])
}
(2). Render to the page