cv-upload-avatar 头像上传 ¶
示例 ¶
vue
<template>
<view class="content">
<view class="components-title">
<view class="components-title-t">cv-upload-avatar</view>
<view class="components-title-d">头像上传</view>
</view>
<cv-upload-avatar v-model="formData.name" />
</view>
</template>
<script>
export default {
data() {
return {
formData: {
name: ''
},
jiage1: '0',
jiage2: '0',
name: ''
};
},
onLoad() {
setTimeout(() => {
this.$testReqMock().then((res) => {
this.name = '小明';
this.formData.name = '小红';
});
console.log('模拟请求数据', this.formData, this.name);
}, 1000);
},
methods: {
bindTimeChange(e) {},
clickTest(e) {
console.log(this.formData.name);
}
}
};
</script>
vue
<template>
<view>
<cv-upload-avatar v-model="formData.img" :src="formData.img_original" />
</view>
</template>
<script>
export default {
data() {
return {
formData: {
img: '',//双向绑定
img_original: ''//默认值
},
};
}
}
</script>
属性 ¶
属性名 | 类型 | 默认值 | 说明 |
---|---|---|---|
v-model | String | - | 图片地址 |
src | String | - | 展示 |
apiFunc | Function | - | 上传方法 |