<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                合規國際互聯網加速 OSASE為企業客戶提供高速穩定SD-WAN國際加速解決方案。 廣告
                [TOC] ## 安裝 ``` npm i vuex ``` ## 目錄結構 ![](https://img.kancloud.cn/2e/5e/2e5e4cdfc6586abd15f24da1090b2a5b_570x470.jpg) ## 核心概念 ### Getter - 以`state`數據為基準,創建新的數據 ``` const store = new Vuex.Store({ state: { todos: [ { id: 1, text: '...', done: true }, { id: 2, text: '...', done: false } ] }, getters: { doneTodos: state => { return state.todos.filter(todo => todo.done) } } }) //訪問 this.$store.getters.doneTodosCount ``` ### Mutation - store 中的狀態的唯一方法 ``` const store = new Vuex.Store({ state: { count: 1 }, mutations: { increment (state, n) { state.count += n } }) //調用 store.commit('increment', 10) ``` ### actions Action 可以包含任意異步操作。 Action 提交的是 mutation ## 簡單調用 ``` const Counter = { template: `<div>{{ count }}</div>`, computed: { count () { return this.$store.state.count } } } ``` ## 把state中的值放到計算屬性中 在 vue 中監聽 vuex 值的變化 如: `store/index.js` ``` ... state: { forcedLogin: false, hasLogin: false, userName: "" }, ... ``` 在 `.vue`中 ``` import { mapState } from 'vuex' export default { computed: mapState(['forcedLogin', 'hasLogin', 'userName']), } ``` ## vue中監聽 vuex 屬性的變化 ``` '$store.state.currentGlobal':function () { todo(this.$store.state.currentGlobal); } ```
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看