Javascript 我试图使用选择列表中的值,但没有成功

Javascript 我试图使用选择列表中的值,但没有成功,javascript,select,vue.js,Javascript,Select,Vue.js,我在vue组件的模板中有: <td> <select id="papel" @change="intervChange(row)"> <option value="Apreciador">Apreciar</option> <option value="Assessor">Assessorar</option> <option value="Comunicador">Comunicar

我在vue组件的模板中有:

<td>
  <select id="papel" @change="intervChange(row)">
    <option value="Apreciador">Apreciar</option>
    <option value="Assessor">Assessorar</option>
    <option value="Comunicador">Comunicar</option>
    <option value="Decisor">Decidir</option>
    <option value="Executor">Executar</option>
    <option value="Iniciador">Iniciar</option>
  </select>
</td>

这种方法有什么问题?

实际上,问题在于函数调用 您使用了@change=intervChangerow 现在,这个行参数是造成问题的原因。 只要从函数中删除数据参数,从函数调用中删除行,它就可以工作了

function intervChange() {

     var i = document.getElementById("papel");
     console.log(i.selectedIndex);
     var typeInterv = i.options[i.selectedIndex].value;
     console.log(typeInterv)
 }
<select id="papel" onchange="intervChange();">
    <option value="Apreciador">Apreciar</option>
    <option value="Assessor">Assessorar</option>
    <option value="Comunicador">Comunicar</option>
    <option value="Decisor">Decidir</option>
    <option value="Executor">Executar</option>
    <option value="Iniciador">Iniciar</option>
  </select>

我对此进行了测试,结果很有效

我使用了一个vue子组件,现在是一个通用子组件:

<td>
  <select id="papel" @change="intervChange(row)">
    <option value="Apreciador">Apreciar</option>
    <option value="Assessor">Assessorar</option>
    <option value="Comunicador">Comunicar</option>
    <option value="Decisor">Decidir</option>
    <option value="Executor">Executar</option>
    <option value="Iniciador">Iniciar</option>
  </select>
</td>
Vue.组件“从列表中选择值”{ 模板:` {{op.label}} `, 道具:{ 选项:{ 类型:数组, 必填项:true } }, 数据:函数{ 返回{ 当前值:APPRECIADOR } }, 观察:{ 当前值:函数{ this.$emit'value-change',this.current-value; } }
} 我想你想这样

<td>
<select id='app' @change=intervChange() >
    <option v-for='op in options' :value='op.value'>{{op.text}}</option>
</select>
</td>

<script>
    var vm= new Vue({
        el: '#app',
        data: {
            options: [
                {value:"Apreciador", text:'Apreciar'},
                {value:"Assessor", text:'Assessorar'},
                {value:"Comunicador", text:'Comunicar'},
                {value:"Decisor", text:'Decidir'}
            ]
        },
        methods:{
            intervChange: function() {
                opindex=this.$el.selectedIndex
                opvalue=this.options[opindex].value;
                console.log(opindex +':'+opvalue);
            }
        }
    });
</script>

因此,您选择了一些内容并调用intervChangerow,但console.logi.selectedIndex;只返回0?顺便说一句,如果不使用数据参数,为什么会有数据参数?为什么不使用v-model?使用v-model很容易操作数据是的,但我想更改函数内的行,以便将新值传递给父组件。。。