报错: image.png
源码:从vuex中拿出history里面的Items数组,然后对其进行遍历,结果报了上面的错误
对应的vue文件
...mapState({
history: state => state.history.all
}),
currStatus() {
return this.history.status;
}
},
watch: {
currStatus(value) {
if (this.currStatus == 1) {
let that = this;
let arr = [];
// 状态监测
console.log("that.history--->", that.history);
arr = that.history.Items;
for (let i = 0; i < arr.length; i++) {
const item = arr[i];
if (item.TId) {
that.TIds.push(item.TId);
}
if (item.EId) {
that.EIds.push(item.EId);
}
}
对应的store文件
import history from './../../../../api/AppService/SampleCard/History'
// initial state
const state = {
all: {
status:-1, // 1:正常返回结果,2:接口异常,3:网络异常
code: "",
Items:[]
},
params:{
Begin:'',
End :'',
Next_Date:'',
TIds:'',
EIds:''
},
type:true,
}
// getters
const getters = {}
// actions
const actions = {
history ({ commit }) {
history.History((tools) => {
commit('sethistory',tools)
},state.params,state.type);
}
}
// mutations
const mutations = {
sethistory (state, tools) {
state.all.status = tools.status;
if(state.all.status == 1){
state.all.Items = tools.Items;
}
},
setParams(state,params){ //设置参数
state.params = params;
},
setStatus(state,status){
state.all.status = status;
},
setType(state,type){
state.type = type;
},
setAll(state,all){
state.all = all;
}
}
网友评论