I'm using vuetify components for front-end in Vuejs. I want to create a user registeration form with file upload. I'm able to create a form using v-text-field
in vuetify but how to upload the file. Which component to use or any other alternative way.
相关问题
- Is there a limit to how many levels you can nest i
- How to toggle on Order in ReactJS
- void before promise syntax
- Keeping track of variable instances
- Can php detect if javascript is on or not?
This is something we will add in the future, but not currently. There is discussion on github with several users posting their implementations that they are using for the time being, https://github.com/vuetifyjs/vuetify/issues/238
An easy trick is:
Just create an input with the following properties:
type=file
ref=inputUpload
this works like an id, you could name it like you wantv-show=false
this hides inputThen make a button that when you click it, it fires a click event on the input Upload Button.
Good news.
Starting with version 2.0.0.-beta.8
v-file-input
is available in Vuetify. You're supposed to use it like:EDIT (SNIPPET ADDITION):
A basic usage for handling an image file can be implemented as follows.
Thanks to @Begueradj pointing there is even no need for handling
@change
event for tracking the file change and making the example even more precise:Vue JS do not have file-input feature till today, so you can tweak v-text-field to work like image input field. The concept is, create an file input field and then hide it using css, and add an event in v-text-field to trigger that specific file input field to upload image. I have attached snippet please do play with that, and I also do have a fiddle created using vue and vuetify, visit here. Thanks!
Latest version (V2.0.5) while editing this post dated Aug 11, 2019, there's a dedicated file input option. Please follow the link below for official documentation: https://vuetifyjs.com/en/components/file-inputs.