Commit b4ad6c18c4078c55148864d159c735f72428cc72
Committed by
小小鲁班
1 parent
25155a74
[fix] string 和number隐式转换问题&去除 %支持 拖拽的时候会导致计算问题
Showing
2 changed files
with
7 additions
and
13 deletions
front-end/h5/src/components/core/editor/right-panel/props.js
| @@ -127,7 +127,7 @@ export default { | @@ -127,7 +127,7 @@ export default { | ||
| 127 | */ | 127 | */ |
| 128 | onPositionChange (value, key) { | 128 | onPositionChange (value, key) { |
| 129 | this.setElementPosition({ | 129 | this.setElementPosition({ |
| 130 | - [key]: value | 130 | + [key]: Number(value) |
| 131 | }) | 131 | }) |
| 132 | }, | 132 | }, |
| 133 | /** | 133 | /** |
| @@ -140,7 +140,7 @@ export default { | @@ -140,7 +140,7 @@ export default { | ||
| 140 | const { type, label, key } = item | 140 | const { type, label, key } = item |
| 141 | const data = { | 141 | const data = { |
| 142 | props: { | 142 | props: { |
| 143 | - placeholder: `请输入${key},支持 %单位` | 143 | + placeholder: `请输入${key}` |
| 144 | }, | 144 | }, |
| 145 | domProps: { | 145 | domProps: { |
| 146 | value: commonStyle[key] | 146 | value: commonStyle[key] |
front-end/h5/src/components/core/models/element.js
| @@ -75,13 +75,7 @@ class Element { | @@ -75,13 +75,7 @@ class Element { | ||
| 75 | 75 | ||
| 76 | return pluginProps | 76 | return pluginProps |
| 77 | } | 77 | } |
| 78 | - getPositionValue (key, isRem = false) { | ||
| 79 | - const pluginProps = this.pluginProps | ||
| 80 | - const commonStyle = this.commonStyle | ||
| 81 | - const value = pluginProps[key] || commonStyle[key] | ||
| 82 | - const isPercent = /^\d+%$/.test(value) | ||
| 83 | - return isPercent ? value : parsePx(value, isRem) | ||
| 84 | - } | 78 | + |
| 85 | getStyle ({ position = 'static', isRem = false } = {}) { | 79 | getStyle ({ position = 'static', isRem = false } = {}) { |
| 86 | if (this.name === 'lbp-background') { | 80 | if (this.name === 'lbp-background') { |
| 87 | return { | 81 | return { |
| @@ -92,10 +86,10 @@ class Element { | @@ -92,10 +86,10 @@ class Element { | ||
| 92 | const pluginProps = this.pluginProps | 86 | const pluginProps = this.pluginProps |
| 93 | const commonStyle = this.commonStyle | 87 | const commonStyle = this.commonStyle |
| 94 | let style = { | 88 | let style = { |
| 95 | - top: this.getPositionValue('top', isRem), | ||
| 96 | - left: this.getPositionValue('left', isRem), | ||
| 97 | - width: this.getPositionValue('width', isRem), | ||
| 98 | - height: this.getPositionValue('height', isRem), | 89 | + top: parsePx(pluginProps.top || commonStyle.top, isRem), |
| 90 | + left: parsePx(pluginProps.left || commonStyle.left, isRem), | ||
| 91 | + width: parsePx(pluginProps.width || commonStyle.width, isRem), | ||
| 92 | + height: parsePx(pluginProps.height || commonStyle.height, isRem), | ||
| 99 | fontSize: parsePx(pluginProps.fontSize || commonStyle.fontSize, isRem), | 93 | fontSize: parsePx(pluginProps.fontSize || commonStyle.fontSize, isRem), |
| 100 | color: pluginProps.color || commonStyle.color, | 94 | color: pluginProps.color || commonStyle.color, |
| 101 | // backgroundColor: pluginProps.backgroundColor || commonStyle.backgroundColor, | 95 | // backgroundColor: pluginProps.backgroundColor || commonStyle.backgroundColor, |