Vue dynamic binding model failed

for example,

currently under this vue component, there is a variable key whose value is tel,. I want an input component to bind to different variables according to this key value. For example, when key is a tel string, bind to "create.form."+key, that is, bind to create.form.key. This is dynamic binding. Excuse me, can this binding be implemented in vue?

<Input :v-model=""create.form."+a"></Input>

where an is" tel"

or even

<Input :v-model=""create.form.tel""></Input>

after binding, the actual modification of create.form.tel data is not reflected in the input input box, indicating that it is not bound. What is the reason? Does vue not allow this binding?

Mar.06,2021

this question can be solved with computed , the following code

  <input v-model='com'>
  data () {
    return {
      type: 'a',
      form: {
        a: 123,
        b: 321
      }
    }
  },
  computed: {
    com () {
      return this.form[this.type]
    }
  },
  created () {
    setTimeout(() => {
      this.type = 'b'
    }, 1000)
  }

(Why do you want to change the key dynamically instead of the value dynamically?


you actually bind to a string like this

Grammatical sugar of

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e54d67-452e5.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e54d67-452e5.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?