reactjs - 反应构造函数中的错误
问题描述
我的元素中有这个构造函数
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
已卸载(或未能安装)的组件。”。但是重新加载后它工作正常。我该如何解决这个错误?
解决方案
推荐阅读
- android - 如果设备处于打盹模式,则在 Android > 7.0 中以编程方式检测来电并在此之后立即发出服务器请求
- node.js - Gmail API getMessage 方法为从 listHistory 方法获取的消息返回 404
- sql-server - Postgresql 中的“页面预期寿命”
- mongodb - 获取内部服务器错误而不是响应状态和正文
- python - 使用 VBA 或 Python 从 URL 列表下载图像
- git - git 中的新分支默认跳过 --set-upstream
- .htaccess - 我需要有关 .htaccess 的帮助
- python - 用 Python PyQT5 掷骰子
- php - 在php的数据库中的同一行中插入具有相同名称的表单输入值
- image - 仅在 android 上使用referrer 响应本机图像请求。我如何在 ios 上完成这项工作?