提交 81dece8f authored 作者: wangjiahao's avatar wangjiahao

feat: 上传图片 增加尺寸控制

上级 ba3117fb
...@@ -175,6 +175,10 @@ export default { ...@@ -175,6 +175,10 @@ export default {
const fileResult = res.target.result const fileResult = res.target.result
const img = new Image() const img = new Image()
img.onload = () => { img.onload = () => {
const scaleWith = img.width / 400
const scaleHeight = img.height / 200
let scale = scaleWith > scaleHeight ? scaleWith : scaleHeight
scale = scale > 1 ? scale : 1
this.$store.commit('addComponent', { this.$store.commit('addComponent', {
component: { component: {
...commonAttr, ...commonAttr,
...@@ -187,8 +191,8 @@ export default { ...@@ -187,8 +191,8 @@ export default {
...commonStyle, ...commonStyle,
top: 0, top: 0,
left: 0, left: 0,
width: img.width, width: img.width / scale,
height: img.height height: img.height / scale
} }
} }
}) })
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论