|
|
@@ -46,10 +46,10 @@
|
|
|
type: Array,
|
|
|
default: null // () => [100, 100]
|
|
|
},
|
|
|
- imgRadio: {
|
|
|
- type: Boolean,
|
|
|
- default: false
|
|
|
- },
|
|
|
+ // imgRadio: {
|
|
|
+ // type: Boolean,
|
|
|
+ // default: false
|
|
|
+ // },
|
|
|
// 允许上传的文件格式后缀名 eg:["jpg", "png"],['*']为不限制,各类型有默认限制 参见: formatDefault
|
|
|
format: {
|
|
|
type: Array,
|
|
|
@@ -429,37 +429,37 @@
|
|
|
// 图片
|
|
|
let maxImgPx = this.maxImgPx
|
|
|
let imgRadio = this.imgRadio
|
|
|
- if(imgRadio) {
|
|
|
- try {
|
|
|
- await new Promise((resolve) => {
|
|
|
- let width, height
|
|
|
- let image = new Image()
|
|
|
- image.onload = () => {
|
|
|
- width = image.width
|
|
|
- height = image.height
|
|
|
- if((width / height).toFixed(2) !== (16/9).toFixed(2)) {
|
|
|
- this.$message.error('上传图片比例必须为16:9')
|
|
|
- validate = false
|
|
|
- }
|
|
|
- window.URL && window.URL.revokeObjectURL(image.src)
|
|
|
- resolve()
|
|
|
- }
|
|
|
- if (window.URL) {
|
|
|
- let url = window.URL.createObjectURL(file)
|
|
|
- image.src = url
|
|
|
- } else if (window.FileReader) {
|
|
|
- let reader = new FileReader()
|
|
|
- reader.onload = function (e) {
|
|
|
- let data = e.target.result
|
|
|
- image.src = data
|
|
|
- }
|
|
|
- reader.readAsDataURL(file)
|
|
|
- }
|
|
|
- })
|
|
|
- } catch (e) {
|
|
|
- console.error(e)
|
|
|
- }
|
|
|
- }
|
|
|
+ // if(imgRadio) {
|
|
|
+ // try {
|
|
|
+ // await new Promise((resolve) => {
|
|
|
+ // let width, height
|
|
|
+ // let image = new Image()
|
|
|
+ // image.onload = () => {
|
|
|
+ // width = image.width
|
|
|
+ // height = image.height
|
|
|
+ // if((width / height).toFixed(2) !== (16/9).toFixed(2)) {
|
|
|
+ // this.$message.error('上传图片比例必须为16:9')
|
|
|
+ // validate = false
|
|
|
+ // }
|
|
|
+ // window.URL && window.URL.revokeObjectURL(image.src)
|
|
|
+ // resolve()
|
|
|
+ // }
|
|
|
+ // if (window.URL) {
|
|
|
+ // let url = window.URL.createObjectURL(file)
|
|
|
+ // image.src = url
|
|
|
+ // } else if (window.FileReader) {
|
|
|
+ // let reader = new FileReader()
|
|
|
+ // reader.onload = function (e) {
|
|
|
+ // let data = e.target.result
|
|
|
+ // image.src = data
|
|
|
+ // }
|
|
|
+ // reader.readAsDataURL(file)
|
|
|
+ // }
|
|
|
+ // })
|
|
|
+ // } catch (e) {
|
|
|
+ // console.error(e)
|
|
|
+ // }
|
|
|
+ // }
|
|
|
if (maxImgPx) {
|
|
|
try {
|
|
|
await new Promise((resolve) => {
|