一:子组件不更新问题webpack
第一种 //子组件:点击事件 handleClick(ev,index){ //提交事件 this.props.onHandleButtonClick(index) //更新子组件渲染 :this.props为父组件更新的数据 this.componentWillReceiveProps(this.props) } //更新操做 componentWillReceiveProps =(nextProps)=>{ this.setState({ demandType: nextProps.demandType }) } 第二种 //父组件直接定义数据 handleButtonClick(index){ //注意 下面多了一个() this.setState((state)=>({ demandType:tyleList })) }
二:import 访问路径再也不须要使用../.../多层查找。web
// webpack.config.js ,设置之后记得从新运行。 module.exports = { resolve:{ extensions:['.js','.jsx'], //添加一下代码,请注意/app此地址,若是咱们的目录结果是src为主目录则写src。 alias:{ '@':`${__dirname}/app/` } }, } //调用 import Children from '@/components/Children';