Commit 9e8e89fc31766b26f251f6bc6d379c21d8ce0618
1 parent
28a03103
feat(editor): mixin custom component for plugin props into editor
Showing
1 changed file
with
14 additions
and
1 deletions
front-end/h5/src/views/Editor.vue
| @@ -203,7 +203,12 @@ const LbpButton = { | @@ -203,7 +203,12 @@ const LbpButton = { | ||
| 203 | }), | 203 | }), |
| 204 | computed: { | 204 | computed: { |
| 205 | value_: { | 205 | value_: { |
| 206 | - get: () => this.value, | 206 | + // TODO 关于箭头函数中的this:这里不能写成箭头函数,否则 this 为 undefined,为何? |
| 207 | + // http://davidshariff.com/blog/what-is-the-execution-context-in-javascript/ | ||
| 208 | + // https://tangxiaolang101.github.io/2016/08/01/%E6%B7%B1%E5%85%A5%E6%8E%A2%E8%AE%A8JavaScript%E7%9A%84%E6%89%A7%E8%A1%8C%E7%8E%AF%E5%A2%83%E5%92%8C%E6%A0%88%EF%BC%88What%20is%20the%20Execution%20Context%20&%20Stack%20in%20JavaScript%EF%BC%89/ | ||
| 209 | + get () { | ||
| 210 | + return this.value | ||
| 211 | + }, | ||
| 207 | set (val) { | 212 | set (val) { |
| 208 | this.$emit('input', val) | 213 | this.$emit('input', val) |
| 209 | } | 214 | } |
| @@ -350,8 +355,16 @@ const Editor = { | @@ -350,8 +355,16 @@ const Editor = { | ||
| 350 | const editorConfig = this.getEditorConfig(name) | 355 | const editorConfig = this.getEditorConfig(name) |
| 351 | this.elements.push(new Element({ name, zindex, editorConfig })) | 356 | this.elements.push(new Element({ name, zindex, editorConfig })) |
| 352 | }, | 357 | }, |
| 358 | + mixinPluginCustomComponents2Editor () { | ||
| 359 | + const { components } = this.editingElement.editorConfig | ||
| 360 | + for (const key in components) { | ||
| 361 | + if (this.$options.components[key]) return | ||
| 362 | + this.$options.components[key] = components[key] | ||
| 363 | + } | ||
| 364 | + }, | ||
| 353 | setCurrentEditingElement (element) { | 365 | setCurrentEditingElement (element) { |
| 354 | this.editingElement = element | 366 | this.editingElement = element |
| 367 | + this.mixinPluginCustomComponents2Editor() | ||
| 355 | }, | 368 | }, |
| 356 | /** | 369 | /** |
| 357 | * #!zh: renderCanvas 渲染中间画布 | 370 | * #!zh: renderCanvas 渲染中间画布 |