S
S
semki0962019-04-19 16:33:04
Vue.js
semki096, 2019-04-19 16:33:04

How to show its preview when uploading a file, using vue.js as an example?

In data - I have downloadable files from <input type="file">.

new Vue({
    el: '#app',
    data: function (){
                  return {
                    files: []
                  }
},
....................

Then I display the names of the files in a loop
<ul>
        <li v-for="file in files">
                <p>{{file.name}}</p>
        </li>
</ul>`

Question - how to display its preview next to the file name? Interested in vue.js way. I would be grateful for a hint.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
K
Kiryushka Tsisar, 2019-04-19
@semki096

Your input should have an @change function, for example, which you write to an array through e.target.files, new fileReader and readAsDataURL(), and in the loop already output img with src="data"

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question