单击另一个按钮时 Quasar 切换 q 文件
Quasar toggle q-file when another button is clicked
在 Quasar 框架中,当我单击某个按钮时如何切换文件选择器 q-file
。
我目前的努力:
单击此按钮时,它应该切换 q-file
<button @click="toggleFileSelector">toggle file selector</button>
所以我有这个文件选择器,我希望它在我单击按钮时切换
<q-file outlined class="field" ref="myFileSelector" :label="label" v-model="myFile">
<template v-slot:append>
<div class="attachment notosanskr-medium">File</div>
</template>
</q-file>
切换方法:
methods: {
toggleFileSelector() {
this.$refs.myFileSelector.toggle();
},
},
但我得到一个错误:
"TypeError: this.$refs.myFileSelector.toggle is not a function"
是的,您可以通过 ref 切换输入。您需要调用 pickFiles
函数。
示例 - this.$refs.file.pickFiles();
<q-file ref="file" clearable filled color="purple-12" v-model="model" label="Label"></q-file>
<q-btn @click="testclick" color="primary" label="Click"></q-btn>
methods:{
testclick(){
this.$refs.file.pickFiles();
}
}
在 Quasar 框架中,当我单击某个按钮时如何切换文件选择器 q-file
。
我目前的努力:
单击此按钮时,它应该切换 q-file
<button @click="toggleFileSelector">toggle file selector</button>
所以我有这个文件选择器,我希望它在我单击按钮时切换
<q-file outlined class="field" ref="myFileSelector" :label="label" v-model="myFile">
<template v-slot:append>
<div class="attachment notosanskr-medium">File</div>
</template>
</q-file>
切换方法:
methods: {
toggleFileSelector() {
this.$refs.myFileSelector.toggle();
},
},
但我得到一个错误:
"TypeError: this.$refs.myFileSelector.toggle is not a function"
是的,您可以通过 ref 切换输入。您需要调用 pickFiles
函数。
示例 - this.$refs.file.pickFiles();
<q-file ref="file" clearable filled color="purple-12" v-model="model" label="Label"></q-file>
<q-btn @click="testclick" color="primary" label="Click"></q-btn>
methods:{
testclick(){
this.$refs.file.pickFiles();
}
}