总结几个页面延时显示数据的问题

252 阅读1分钟

问题描述:

接口数据返回正确,但是页面显示的却是上一步**上一步**操作返回的数据

场景及解决方法

  1. 搜索栏表单提交时

搜索栏

如果在下拉框的onChange事件中,获取的表单数据为上一步操作的数据。此时增加一个查询按钮,点击按钮后提交表单。即获得当前表单内的数据。

2.父组件给子组件传值时,父组件数据更新了,而子组件数据未更新

年月日切换操作在父页面,图表为子组件。此时,子组件使用componentWillReceiveProps生命周期,应使用nextProps来接收父组件的传值。
componentWillReceiveProps(nextProps){
    this.myChart = echarts.init(document.getElementById(this.props.id));
    this.myChart.setOption(nextProps.option || this.state.option);
}