baidu / baidu/amis

请问sdk方式在表单中自定义组件,如何获取该组件的value,谢谢

Open
#4,834 1 comment 0 reactions 0 assignees View on GitHub
doc
Dominant language
TypeScript
Stars
18.9k
Forks
2.7k
PR merge metrics
No merged PRs in 30d

Description

```
自定义的组件会修改一些props中的值,作为组件的value,
如文档中例子,amis有默认传给组件的函数,用于组件把值提升上来,进而设置value么?

注意到custom中的onMount可以修改,sdk是否也可以用相同的方式取值?
谢谢~

{
type: 'page',
title: '表单页面',
body: {
type: 'form',
title: 'custom 组件',
body: [
{
type: 'custom',
name: 'myName',
label: '自定义组件',
onMount: (dom, value, onChange, props) => {
const button = document.createElement('button');
button.innerText = '点击修改';
button.onclick = event => {
onChange('new'); // 这个 onChange 方法只有放在表单项中才能调用
event.preventDefault();
};
dom.appendChild(button);
}
}
]
}
}

```

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by comparing the custom component's onMount/onChange example with the SDK form integration described in the issue. Identify the relevant SDK entry point and existing value-propagation behavior; done requires a documented, reproducible way to update myName from the component, with the example verified.

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
20/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.