javascript - Quasar toggle q-file when another button is clicked - Stack Overflow

In Quasar framework how can I toggle the file selector q-file when I click certain button.My effort so

In Quasar framework how can I toggle the file selector q-file when I click certain button.

My effort so far:

when this buton is click it should toggle the q-file

<button @click="toggleFileSelector">toggle file selector</button>

so I have this File-selector and I want this to toggle when I click on a 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>

the method to toggle:

  methods: {
    toggleFileSelector() {
      this.$refs.myFileSelector.toggle();
    },
  },

but I get an error:

"TypeError: this.$refs.myFileSelector.toggle is not a function"

In Quasar framework how can I toggle the file selector q-file when I click certain button.

My effort so far:

when this buton is click it should toggle the q-file

<button @click="toggleFileSelector">toggle file selector</button>

so I have this File-selector and I want this to toggle when I click on a 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>

the method to toggle:

  methods: {
    toggleFileSelector() {
      this.$refs.myFileSelector.toggle();
    },
  },

but I get an error:

"TypeError: this.$refs.myFileSelector.toggle is not a function"

Share Improve this question asked Oct 18, 2020 at 23:57 EvanEvan 2,5076 gold badges38 silver badges71 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 8

Yes, you can toggle input by ref. You need to call pickFiles function.

Example - 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();
    }
  }

codepen- https://codepen.io/Pratik__007/pen/dyXpXgr

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744282207a4566625.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信