基于vue.js中关于下拉框的值默认及绑定问题
时间:2021-05-25 08:21:32|栏目:vue|点击: 次
一、今天遇到vue中下拉框问题,故而写点东西留个脚印
<template> <select v-model='selected' @click="disable()"> <option v-for="(option,index) in options" v-bind:value="option.value" :disabled="option.disabled"> {{ option.text }}{{index}}{{option.disabled}} </option> </select> <span>Selected: {{ selected }}</span> </template> <script> export default{ name: 'second', data(){ return { selected: 'sex', // 这里选择默认项 options: [ {text: '点击选择性别', value: 'sex', disabled: ''}, {text: '男', value: '1'}, {text: '女', value: '2'} ] } }, methods: { disable: function () { this.options[0].disabled = disabled; }, } } </script>
栏 目:vue
本文地址:http://www.codeinn.net/misctech/128392.html