alibaba / alibaba/lowcode-engine

addBuiltinComponentAction 时机能否获取组件的 this scope 值?

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

Description

背景:想给组件增加一个 action 操作获取当前组件的 this 值,用来做数据绑定的时候方便找到具体层级。

想通过 https://lowcode-engine.cn/site/docs/api/material#%E8%AE%BE%E8%AE%A1%E5%99%A8%E8%BE%85%E5%8A%A9%E5%B1%82 时机获取组件 this 值。

```js
material.addBuiltinComponentAction({
name: 'myIconName',
content: {
icon: () => 'x',
title: 'hover title',
action(node) {
console.log('log => ~ action ~ node:', node)
console.log('myIconName 扩展位被点击')
},
},
important: true,
condition: true,
})

```

目前获取到的 node 如下图:

![image](https://github.com/alibaba/lowcode-engine/assets/40717741/1203b5f0-5771-4ba1-90ef-809016879b0d)

https://lowcode-engine.cn/site/docs/api/model/node

想要获取的 this 如下,现在都通过console 去调试找数据,很麻烦
![image](https://github.com/alibaba/lowcode-engine/assets/40717741/3c1e84ff-46df-4838-ac39-bed3f89f53c1)

![image](https://github.com/alibaba/lowcode-engine/assets/40717741/519f6870-da03-43a5-bc54-e335ffac8fe8)

---

大概调试了下,没找到 node 怎么获取到 scope/this

![image](https://github.com/alibaba/lowcode-engine/assets/40717741/848427e7-605e-42c0-afcf-83b053cf5c7d)

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with the material.addBuiltinComponentAction API and the linked designer-helper and node model documentation, then inspect how the action callback receives node. Done means the action can access the current component's this scope or an explicitly documented equivalent without console debugging.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
frontend
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.