alibaba / alibaba/lowcode-engine

预览和实际效果不一致,编写的表达式中获取不到ref

Open
#1,317 4 comments 0 reactions 0 assignees View on GitHub
insufficient information
Dominant language
TypeScript
Stars
15.9k
Forks
2.7k
PR merge metrics
No merged PRs in 30d

Description

```
getFormValue(key){
return this.$('form_jxks').getFieldsValue()[key]
}

equalExpression(key, val){
const res = this.getFormValue(key);
return Array.isArray(val) ? val.includes(res) : val === res ;
}
```

```
{!!__$$eval(() =>
this.equalExpression("have_special_notify_config", "2")
) && (

`特殊配置「${
this.equalExpression("default_notify_action", "2")
? "不发通知"
: "发通知"
}」`
)}
```

这是生成的代码, 这段逻辑主要是想,根据用户表单填写的值,去控制Card组件的显隐, 生成的代码截选如上,
经过调试代码发现,根本拿不到ref, this.$('form_jxks') 运行结果是 null,直接被__$$eval 的try catch 捕获了。但是令我疑惑的
是,我在配置完成后,点击的预览,那里却显示正常, 预览时有什么魔法么?

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by comparing the preview path with the generated-code path around __$$eval and this.$('form_jxks'), reproducing the form-value expression in both contexts. Confirm why the ref is null outside preview and document the behavior or fix so the generated Card visibility and title evaluate consistently.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
frontend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.