<template>
    <div>
        <div class='add_photo'>
            <van-uploader :after-read="onRead">
                <van-icon v-if='!uploaded' name="photograph" size="50px"/>
                <img :src="photo.content" v-if='uploaded' style="max-height: 90px"/>
            </van-uploader>
        </div>
    </div>
</template>

<script>
    import {
        Uploader, Icon,
    } from 'vant'
    export default {
        name: "addPhoto",
        components: {
            [Uploader.name]: Uploader, [Icon.name]: Icon,
        },
        props: {
            uploaded: {
                type: Boolean,
                default:false
            },
            photo: {
                type: Object,
                default: null
            },
        },
        methods: {
            onRead(file) {
                this.photo= file;
                this.uploaded = true;
                this.$emit('uploadPhoto', this.photo);
            }
        }
    }
</script>

<style scoped>

</style>