dispatch ,commit区别在vue store

2019-11-11 16:43:43

dispatch: 含有异步操作,commit:同步操作

dispatch: 含有异步操作

存储:

this.$store.dispatch('initUserInfo',friend);

取值:

this.$store.getters.userInfo;

commit:同步操作

存储:

this.$store.commit('initUserInfo',friend);

取值:

this.$store.state.userInfo;
  • 2017-02-09 09:02:26

    两列布局——左侧宽度固定,右侧宽度自适应的两种方法

     关于左侧宽度固定,右侧宽度自适应两列布局的一种很常用的方法我相信大家都知道。就是利用左侧元素浮动,或者绝对定位的方式使其脱离常规文档流,让两个块级元素能够在同一行显示。然后右侧元素 margin-left 的值等于左侧元素宽度,这时右侧元素将紧挨着左侧元素