1.引入image-tools插件
npm i image-tools --save
2.main.js引入插件
import { pathToBase64, base64ToPath } from 'image-tools'
Vue.prototype.pathToBase64 = pathToBase64
Vue.prototype.base64ToPath = base64ToPath
3.封装upload-head.vue
<template>
<view class="upload-head">
<u-upload :fileList="fileList1" @afterRead="afterRead" @delete="deletePic" name="1" :maxCount="1">
</u-upload>
</view>
</template>
<script>
import { mapGetters } from "vuex";
// 回显
export default {
computed: {
...mapGetters(["tempUserInfo"]),
},
props:{
pic:{
type: String,
default: ''
}
},
data() {
return {
fileList1: [],
}
},
mounted() {
//con