If vue, get the bound ID.

there is such an array

category: [
{name:"1",id:1},
{name:"2",id:2},
{name:"3",id:3}
]
then iterate through the page

< select v name= model = "model.parentCategory" name= "category" id= "category" >

  <option v-for="(item,index) in category"  :value="item.id">{{ item.name }}</option>

< / select >

how can I get item.id? -sharp-sharp-sharp problem description
whether you can dispense with jquery

Mar.28,2021

with ref, you can see ide/migration.html-sharpv-el-%E5%92%8Cv-ref-%E6%9B%BF%E6%8D%A2" rel=" nofollow noreferrer "> https://cn.vuejs.org/v2/guide.


vue. You hardly need to operate dom,. You don't understand why you want to get id, even if it's easy. When the rendering is finished, use this.$nextTick in mounted and then js directly to operate dom.


vue can be found on the official website. ide/forms.html-sharp%E9%80%89%E6%8B%A9%E6%A1%86" rel=" nofollow noreferrer "> selection box
clipboard.png


model.parentCategory is the value, of the option you selected, that is, item.id


item.id is id,. Do you want to transfer it to the method when you click? You've got it. Wow!


 <select v-model="model.parentCategory" name="category" id="category" v-on:change="getOption($event)" >
    <option v-for="(item,index) in category" :value="item.id" :key="index">{{ item.name }}</option>
  </select>
        

you can add a change event to select to get the event and write the following
event.target.value is the obtained item.id

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