On the problem of Vue dynamic binding v-model

clipboard.png

question: there is a loop where deeplearning is a list of contents similar to ["lstm0","lstm1","gru0"], but the content of the list changes as the user adds, so it is not fixed. I want to dynamically bind to the element of the list
1. I want to mark the red line part of the v-model. Because the contents of the list are not fixed, I cannot define a variable in data to declare in advance
2. I wrote a dictionary in data, such as

.
result: {
    "lstm0":"",
    "lstm1":""
}

I want to bind it to lstm.item, but this way of writing will lead to direct result.item, instead of result.lstm0,. Is there any way to make v-model "s item a variable? Or provide other methods to implement dynamic binding


v-model='result [item]'

tested, this can achieve two-way binding, I see the above also call functions and so on, so is your item a string
test


first of all, there are two points to be clear:

  • v-model does not need to be preceded by the ":" character, to see if the colon affects the two-way binding, because this does not report an error.
  • result.item represents the use of result ['item'], and if you want item to represent a variable, you must get it with result [item].

based on the request of the subject, I also wrote a small chestnut personal test is ok, you can try.

  

index binding is used when vMub model = "reports.btnsindex" v-for.

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-1b35237-2bf84.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-1b35237-2bf84.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?