vuex使用模块化开发
发布日期:2021-05-10 04:28:13 浏览次数:25 分类:精选文章

本文共 1940 字,大约阅读时间需要 6 分钟。

������ store.js ���������������������vuex��������������������������������������� Vue ��� Vuex������������������������������������������������������������������������������������������������������������������������������ ager ��������� parStore ���������������������������������������������������

Modules/ager.js ������������

ager ������������������������������������������������������������������������������������������������������

  • State��������� tabs ������������������������������������������������
  • Getters���������������������������������������
  • Mutations���������������������������������
    • addTab(state, tab)������������������������ tabs ������
  • Actions������������������������ addTabAsync������������������������������������������������
  • @/pages/par/store ������������

    parStore ������������������������par���������������������������������

  • State��������� id ��� tabs ������
  • Mutations������ ager ��������������������� addTab ������
  • Actions��������������������� addTabAsync ������������
  • Getters������������������
  • ���������������������Vuex

    ���������������������������vuex���������������������������������������������������������������store���������

    import { createNamespacedHelpers } from 'vuex';const { mapState, mapActions } = createNamespacedHelpers('store');

    ������������������������ computed ���������������������������

    computed: {  id() {    return this.mapState({ id: state => state.id });  }},methods: {  addTabAsync() {    return this.mapActions(['addTabAsync']);  }}

    ��������������������������������������� mapState ��� mapActions ������������������������������������������������

    // ������const { panes: { id }, currentId } = createNamespacedHelpers('ager/parStore');

    ������������������������������������������ this.id ������ panes ������������ id ������������������ addTabAsync ������������������������������

    ���������������������������������������������������������������������������������������������������������������������������

    上一篇:@mixin与@include;@import与@extend; /deep/
    下一篇:面试场景,心得体会

    发表评论

    最新留言

    做的很好,不错不错
    [***.243.131.199]2025年04月29日 01时34分25秒