Commit cd43aca4 by 前端

上传组件

1 parent c38d6bcd
......@@ -69,7 +69,13 @@
>
<i class="el-icon-plus avatar-uploader-desc-icon"></i>
<div class="avatar-uploader-desc-word">
上传{{ picOptions.type == "video" ? "视频" : "图片" }}
上传{{
picOptions.noLimitType
? ""
: picOptions.type == "video"
? "视频"
: "图片"
}}
</div>
<input
type="file"
......@@ -77,8 +83,14 @@
class="upload-img"
:style="{ width: picOptions.width, height: picOptions.height }"
style="opacity: 0; z-index: -1"
:accept="picOptions.type == 'video' ? '.mp4' : '.jpg, .jpeg, .png,'"
@change="(e) => handleImgChange(e)"
:accept="
picOptions.noLimitType
? '*'
: picOptions.type == 'video'
? '.mp4'
: '.jpg, .jpeg, .png,'
"
@change="(e) => handleUpload(e)"
/>
</div>
</template>
......@@ -161,6 +173,14 @@ export default {
}
this.$refs.uploadImgRef.click()
},
handleUpload(e) {
console.log(e.srcElement.files[0].type)
if (this.picOptions.noLimitType) {
if (e.srcElement.files[0].type.indexOf("mp4") > -1)
this.picOptions.type = "video"
}
this.handleImgChange(e)
},
// 上传图片
handleImgChange(e) {
var file = e.srcElement.files[0]
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!