[Vuejs]-Trigger b-form-file after clicking on b-button

2๐Ÿ‘

โœ…

You must required to make a method for click on for example:

<b-button variant="danger" @click="open">Upload</b-button>
<b-form-file id="upload"></b-form-file>

<script>
     export default {
          methods: {
            open: ()=> {document.getElementById('upload').click()},
          }
     }
</script>

0๐Ÿ‘

<b-form-file 
    ref="signatureFile" 
    @input="validate(signature)" 
    accept=".jpeg, .jpg, .png"
    v-model="signature" 
    class="d-none" 
    plain
></b-form-file>

<b-button  
    @click="$refs.signatureFile.$el.click();" 
    variant="tertiary"
>
    {{ Signature ? Signature.name : 'Choose File' }}
</b-button>

Leave a comment