我的元素中有此构造函数
constructor(props) {
super(props);
if (!window.stepThree) {
window.stepThree = {
activeLinks: []
}
}
this.state = {
full: window.stepThree.full || "-",
city_type: window.stepThree.city_type || "-",
passportComment: window.stepThree.passportComment || "-",
passportUnit: window.stepThree.passportUnit || "-",
snils: window.stepThree.snils || "-",
order_type_id: 7,
phone: "",
choosenOkveds: window.stepThree.choosenOkveds ? JSON.parse(window.stepThree.choosenOkveds) : [],
};
window.id = window.location.hash.substr(window.location.hash.indexOf('=')).substr(1);
if (window.id) {
axios.get('/api/orders/get/' + window.id).then(response => {
var json = JSON.parse(response.data.data.json);
this.setState({
settlement_type: json.individuals[0].settlement_type,
settlement: json.individuals[0].settlement,
city_type: json.individuals[0].city_type,
choosenOkveds: json.choosenOkveds ? JSON.parse(json.choosenOkveds) : ""
});
window.stepThree = response.data.data;
window.stepThree.json = json;
});
}
if(!window.stepThree.activeLinks[3]) {
window.stepThree.activeLinks.push('/preparation/stepFour/editIP')
}
this.showSubList = this.showSubList.bind(this);
this.treeOkveds = this.treeOkveds.bind(this);
}
但是与this.state相符,当我转到此页面的链接时,出现错误“尝试更新已经卸载(或无法装载)的组件StepFive
。”。但重新加载后,它可以正常工作。我该如何解决该错误?