laravel - vuejs local image preview, how to get the image src?
滿天的星座
滿天的星座 2017-05-16 16:46:32
0
2
548

vuejs local image preview, how to get the image src?

ComponentImagePreview.vue

<template>
    <p class="card text-center" style="width: 16rem;">
        <img class="card-img" :src="imgDataUrl" style="height: 16rem;">
        <p class="card-footer text-muted">
            <input type="file" id="image" name="image" @change="preview($event)">
        </p>
    </p>
</template>

<script>
    export default {
        data(){
            return {
                imgDataUrl: ''
            }
        },
        methods: {
            preview(event){
                this.imgDataUrl = event.target.files;
            }
        }
    }
</script>

Problem:
After clicking a picture, the picture cannot be displayed. src="[object File]" is displayed in the browser debugging window. How should I write it? Can?
The following two ways of writing in the preview method will not work.

event.target.files
event.target.files[0]
滿天的星座
滿天的星座

reply all(2)
为情所困

event.target.value this is src

阿神

console.log(event.target.files) to see what the structure is like

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!