- 博客(2)
- 收藏
- 关注
原创 面试题:react生命周期
面试题:react生命周期一:挂载卸载1、constructor:react数据的初始化,他接收2个参数,props和context。如果要使用这两个参数,就要使用super(),否则会造成this指向错误。2、componentWillMount:用在服务端渲染时使用。组件已经经历了constructor初始化数据,但还未渲染DOM.3、componentDidMount:组件第一次渲染完成,dom节点已生成。可以在这里请求ajax,返回数据setState后,组件会重新渲染。
2021-09-21 10:43:22
340
原创 vuex这一块的代码
vuex这一块的代码let store = new Vue.Store({ state: { totalPrice: 0 }, getters: { getTotal (state) { return state.totalPrice }, // mutations只能同步的请求 mutations: { increment (state, price) { state.totalPrice += price }, decrement (state,price)
2020-05-15 10:20:08
98
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人