Using @click In Select Options - Vue.js 2 September 11, 2023 Post a Comment I'd like to use @click in select options. So far I have: sort by namesort by priceSolution 1: You can't bind event to <option>, and you need to use the change event of the <select>, once you click a option, the change event callback of select will be invoked:<select name="sortBy" id="sortBy"@change="sortBy(sortType)" v-model="sortType"> <optionv-for="item in sortOptions":value="item.value">{{item.text}}</option> </select> newVue({ el: '...', data: { sortType: 'sort', sortOptions: [ { text: 'sort by', value: 'sort' }, { text: 'name', value: 'name' }, { text: 'price', value: 'price' } ] } }) CopyOnce you change a option the value of sortTyoe will be changed to it, and the @change will call the callback sortBy(sortType). Baca JugaHow Do I Change The Arrow Icon Inside The Select Tag With A Fontawesome Icon. I Am Using Vue-cli. I Have Imported Fontawesome In Main.jsUsing Vuejs Plugin On The Main.js FileHow Vuejs Knows The Depenedencies Of Computed Property For Caching? Share You may like these postsJavascript Closure And The This ObjectAsynchronous Google Maps Request Throwing Off JavascriptHow Does Javascript Execute Code When Duplicate Named Functions Are Declared?Overriding Json.stringify Causing Error Post a Comment for "Using @click In Select Options - Vue.js 2"
Post a Comment for "Using @click In Select Options - Vue.js 2"