Commit 4d86e95d1db067de419e0b3ba9fc937233ac554a
1 parent
845dfae8
feat(element): add defaultStyle for seperate element;
#!zh: 允许通过defaultStyle 给每个元素设置独立的宽高
Showing
2 changed files
with
2 additions
and
9 deletions
front-end/h5/src/components/core/models/element.js
| ... | ... | @@ -32,7 +32,7 @@ class Element { |
| 32 | 32 | * element.pluginProps 和 elementcommonStyle 是引用类型,如果不做 deep_clone 可能会出现意外错误 |
| 33 | 33 | */ |
| 34 | 34 | this.pluginProps = (typeof ele.pluginProps === 'object' && cloneObj({ ...ele.pluginProps, uuid: this.uuid })) || this.getDefaultPluginProps(ele.props || {}) |
| 35 | - this.commonStyle = (typeof ele.commonStyle === 'object' && cloneObj(ele.commonStyle)) || { ...defaultStyle, zindex: ele.zindex } | |
| 35 | + this.commonStyle = (typeof ele.commonStyle === 'object' && cloneObj(ele.commonStyle)) || { ...defaultStyle, zindex: ele.zindex, ...ele.defaultStyle } | |
| 36 | 36 | this.events = [] |
| 37 | 37 | this.animations = ele.animations || [] |
| 38 | 38 | } | ... | ... |
front-end/h5/src/store/modules/element.js
| ... | ... | @@ -39,15 +39,8 @@ export const mutations = { |
| 39 | 39 | |
| 40 | 40 | switch (type) { |
| 41 | 41 | case 'add': |
| 42 | - // value.name => pluginName | |
| 43 | - const { name } = value | |
| 44 | 42 | const vm = getVM(value.name) |
| 45 | - const props = vm.$options.props | |
| 46 | - value = { | |
| 47 | - ...value, | |
| 48 | - zindex: len + 1 | |
| 49 | - } | |
| 50 | - const element = new Element({ name, props }) | |
| 43 | + const element = new Element(vm.$options) | |
| 51 | 44 | elements.push(element) |
| 52 | 45 | break |
| 53 | 46 | case 'copy': | ... | ... |