zoukankan      html  css  js  c++  java
  • Vuex

    Form Handling
    
    When using Vuex in strict mode, it could be a bit tricky to use v-model on a piece of state that belongs to Vuex:
    
    <input v-model="obj.message">
    Assuming obj is a computed property that returns an Object from the store, the v-model here will attempt to directly mutate obj.message when the user types in the input. In strict mode, this will result in an error because the mutation is not performed inside an explicit Vuex mutation handler.
    
    The "Vuex way" to deal with it is binding the <input>'s value and call an action on the input or change event:
    
    <input :value="message" @input="updateMessage">
    // ...
    computed: {
      ...mapState({
        message: state => state.obj.message
      })
    },
    methods: {
      updateMessage (e) {
        this.$store.commit('updateMessage', e.target.value)
      }
    }
    And here's the mutation handler:
    
    // ...
    mutations: {
      updateMessage (state, message) {
        state.obj.message = message
      }
    }
    

      表单处理

  • 相关阅读:
    jquery autocomplete
    hibernate 数据缓存
    Python变量类型
    Python基础语法
    Python环境搭建
    Python简介
    python下载地址
    第十、十一章,软件测试和软件演化
    第九章,软件实现
    第八章,面向对象设计
  • 原文地址:https://www.cnblogs.com/vali/p/8194480.html
Copyright © 2011-2022 走看看