Van*_*anz 2 javascript vue.js vue-component vuejs2 quasar-framework
在 Quasar 框架中,当我单击某个按钮时如何切换文件选择器q-file。
到目前为止我的努力:
当单击此按钮时,它应该切换q-file
<button @click="toggleFileSelector">toggle file selector</button>
Run Code Online (Sandbox Code Playgroud)
所以我有这个文件选择器,我希望在单击按钮时切换它
<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>
Run Code Online (Sandbox Code Playgroud)
切换方法:
methods: {
toggleFileSelector() {
this.$refs.myFileSelector.toggle();
},
},
Run Code Online (Sandbox Code Playgroud)
但我收到错误:
“类型错误:this.$refs.myFileSelector.toggle 不是函数”
是的,您可以通过参考切换输入。您需要调用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();
}
}
Run Code Online (Sandbox Code Playgroud)
codepen- https://codepen.io/Pratik__007/pen/dyXpXgr
| 归档时间: |
|
| 查看次数: |
3698 次 |
| 最近记录: |