wyz123723

vuex 的 action 可以不触发 mutation 吗?

  •  
  •   wyz123723 · Jul 23, 2019 · 2527 views
    This topic created in 2485 days ago, the information mentioned may be changed or developed.
    只是想把业务逻辑一到 store 里去
    1 replies    2019-07-23 19:41:41 +08:00
    SilentDepth
        1
    SilentDepth  
       Jul 23, 2019
    问:一个 Action 是否可以不调用 commit ?
    答:可以。

    问:一个 Action 是否可以不调用 commit 直接修改 state ?
    答:可以。

    问:一个 Action 是否可以不调用 commit 直接修改 state 同时不抛警告?
    答:不可以。(除非你 hack 了 Vuex 的逻辑。)

    问:为什么?
    答:因为 Vuex 的机制就是这样设计的(只能通过 Mutation 修改 state )。
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   933 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 37ms · UTC 20:51 · PVG 04:51 · LAX 13:51 · JFK 16:51
    ♥ Do have faith in what you're doing.