fix: try get settingfield

This commit is contained in:
kangwei 2020-05-29 12:07:47 +08:00
parent 487f257bef
commit 56f242fee9
2 changed files with 12 additions and 2 deletions

View File

@ -294,6 +294,9 @@ export class SettingPropEntry implements SettingEntry {
isUseVariable() {
return isJSExpression(this.getValue());
}
get useVariable() {
return this.isUseVariable();
}
getMockOrValue() {
const v = this.getValue();
if (isJSExpression(v)) {

View File

@ -2,7 +2,7 @@ import { EventEmitter } from 'events';
import { CustomView, isCustomView, IEditor } from '@ali/lowcode-types';
import { computed } from '@ali/lowcode-editor-core';
import { SettingEntry } from './setting-entry';
import { SettingField } from './setting-field';
import { SettingField, isSettingField } from './setting-field';
import { SettingPropEntry } from './setting-prop-entry';
import { Node } from '../../document';
import { ComponentMeta } from '../../component-meta';
@ -124,7 +124,14 @@ export class SettingTopEntry implements SettingEntry {
*
*/
get(propName: string | number): SettingPropEntry {
return new SettingPropEntry(this, propName);
const matched = this.items.find(item => {
if (isSettingField(item)) {
// TODO: thinkof use name or path?
return item.name === propName;
}
return false;
}) as SettingPropEntry;
return matched || (new SettingPropEntry(this, propName));
}
/**