1.
<div class="avatar" style="text-align: center;">
<img :src="avatarUrl ? avatarUrl : defaultAvatar" alt="用户头像图片">
<p style="margin-top: 10px;">
<el-button type="primary" icon="el-icon-upload" @click="showImageCrop" size="small">上传头像</el-button>
</p>
<my-upload
ref="imgCrop"
field="file"
@crop-success="cropSuccess"
@crop-upload-success="cropUploadSuccess"
@crop-upload-fail="cropUploadFail"
:width="300"
:height="300"
:url="uploadUrl"
noRotate
imgFormat="png"
withCredentials
v-model="uploadShow"
:headers="headers"></my-upload>
</div>
2.
computed: {
...mapGetters([
'userId',
'token'
]),
isMobile() {
return this.$store.state.app.isMobile
},
headers() {
return { Authorization: this.$store.getters.authorization }
}
}