<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>

                ThinkChat2.0新版上線,更智能更精彩,支持會話、畫圖、視頻、閱讀、搜索等,送10W Token,即刻開啟你的AI之旅 廣告
                --- title: 從 Vuex 0.6.x 遷移到 1.0 type: guide order: 703 --- > Vuex 2.0 已經發布了,但是這份指南只涵蓋遷移到 1.0?這是打錯了嗎?此外,似乎 Vuex 1.0 和 2.0 也同時發布。這是怎么回事?我該用哪一個并且哪一個兼容 Vue 2.0呢? Vuex 1.0 和 2.0 如下: - 都完全支持 Vue 1.0 和 2.0 - 將在可預見的未來保留支持 然而它們的目標用戶稍微有所不同。 **Vuex 2.0** 從根本上重新設計并且提供簡潔的 API,用于幫助正在開始一個新項目的用戶,或想要用客戶端狀態管理前沿技術的用戶。**此遷移指南不涵蓋 Vuex 2.0 相關內容**,因此如果你想了解更多,請查閱 [Vuex 2.0 文檔](https://vuex.vuejs.org/zh-cn/)。 **Vuex 1.0** 主要是向下兼容,所以升級只需要很小的改動。推薦擁有大量現存代碼庫的用戶,或只想盡可能平滑升級 Vue 2.0 的用戶。這份指南致力促進這一過程,但僅包括遷移說明。完整使用指南請查閱 [Vuex 1.0 文檔](https://github.com/vuejs/vuex/tree/1.0/docs/zh-cn)。 ## 帶字符串屬性路徑的 `store.watch` <sup>替換</sup> `store.watch` 現在只接受函數。因此,下面例子你需要替換: ``` js store.watch('user.notifications', callback) ``` 為: ``` js store.watch( // 當返回結果改變... function (state) { return state.user.notifications }, // 執行回調函數 callback ) ``` 這幫助你更加完善的控制那些需要監聽的響應式屬性。 ``` <div class="upgrade-path"> <h4>升級方法</h4> <p>在代碼庫運行<a href="https://github.com/vuejs/vue-migration-helper">遷移工具</a>,查找在 <code>store.watch</code> 中使用字符串作為第一個參數的事例。</p> </div> ``` ## Store 的事件觸發器 <sup>移除</sup> store 實例不再暴露事件觸發器 (event emitter) 接口 (`on`, `off`, `emit`)。如果你之前使用 store 作為全局的 event bus,遷移說明相關內容請查閱[此章節](migration.html#dispatch-和-broadcast-替換)。 為了替換正在使用觀察 store 自身觸發事件的這些接口,(例如:`store.on('mutation', callback)`),我們引入新的方法 `store.subscribe`。在插件中的典型使用方式如下: ``` js var myPlugin = store => { store.subscribe(function (mutation, state) { // Do something... }) } ``` 更多信息請查閱[插件文檔](https://github.com/vuejs/vuex/blob/1.0/docs/en/plugins.md)的示例。 ``` <div class="upgrade-path"> <h4>升級方式</h4> <p>在代碼庫運行<a href="https://github.com/vuejs/vue-migration-helper">遷移工具</a>,查找使用了 <code>store.on</code>, <code>store.off</code>, <code>store.emit</code> 的事例。</p> </div> ``` ## 中間件 <sup>替換</sup> 中間件被替換為插件。插件是接收 store 作為僅有參數的基本函數,能夠監聽 store 中的 mutation 事件: ``` js const myPlugins = store => { store.subscribe('mutation', (mutation, state) => { // Do something... }) } ``` 更多詳情,請查閱 [插件文檔](https://github.com/vuejs/vuex/blob/1.0/docs/en/plugins.md)。 ``` <div class="upgrade-path"> <h4>升級方法</h4> <p>在代碼庫運行<a href="https://github.com/vuejs/vue-migration-helper">遷移工具</a>,查找使用了 <code>middlewares</code> 選項的事例。</p> </div> ```
                  <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>

                              哎呀哎呀视频在线观看