console
var Main = {
data () {
return {
radio: '1',
img: ''
};
},
methods: {
change (el) {
const file = this.$refs.file.files[0]
const reader = new FileReader()
reader.readAsDataURL(file)
reader.onload = () => {
const _base64 = reader.result
this.img = _base64
}
}
}
}
var Ctor = Vue.extend(Main)
new Ctor().$mount('#app')
<script src="//unpkg.com/vue/dist/vue.js"></script>
<div id="app">
<template>
<div>
<input ref="file" type="file" @change="change">
<img v-if="img" :src="img" width="300">
</div>
</template>
</div>