Commit b4ad6c18c4078c55148864d159c735f72428cc72

Authored by 宋远桥
Committed by 小小鲁班
1 parent 25155a74

[fix] string 和number隐式转换问题&去除 %支持 拖拽的时候会导致计算问题

front-end/h5/src/components/core/editor/right-panel/props.js
... ... @@ -127,7 +127,7 @@ export default {
127 127 */
128 128 onPositionChange (value, key) {
129 129 this.setElementPosition({
130   - [key]: value
  130 + [key]: Number(value)
131 131 })
132 132 },
133 133 /**
... ... @@ -140,7 +140,7 @@ export default {
140 140 const { type, label, key } = item
141 141 const data = {
142 142 props: {
143   - placeholder: `请输入${key},支持 %单位`
  143 + placeholder: `请输入${key}`
144 144 },
145 145 domProps: {
146 146 value: commonStyle[key]
... ...
front-end/h5/src/components/core/models/element.js
... ... @@ -75,13 +75,7 @@ class Element {
75 75  
76 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 79 getStyle ({ position = 'static', isRem = false } = {}) {
86 80 if (this.name === 'lbp-background') {
87 81 return {
... ... @@ -92,10 +86,10 @@ class Element {
92 86 const pluginProps = this.pluginProps
93 87 const commonStyle = this.commonStyle
94 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 93 fontSize: parsePx(pluginProps.fontSize || commonStyle.fontSize, isRem),
100 94 color: pluginProps.color || commonStyle.color,
101 95 // backgroundColor: pluginProps.backgroundColor || commonStyle.backgroundColor,
... ...