使用的是element框架,用vue的watch監(jiān)聽selectValue變化,當變化時就觸發(fā)input[type=file]的click(),但是無效;html 相關代碼<el-select v-model="selectValue" placeholder="請選擇">
<el-option
v-for="item in options"
:key="item.value"
:label="item.label"
:value="item.value">
</el-option></el-select><input type="file" ref="inputFile" id="inputFile">vue 相關代碼data () { return {
options:[{
value: '選項1',
label: '黃金糕'
}, {
value: '選項2',
label: '雙皮奶'
},],
selectValue:''
}
},
watch: {
selectValue: function(v) { // this.$refs.inputFile.click() 無效
// document.getElementById('inputFile').click() 無效
}
}
添加回答
舉報
0/150
提交
取消