React 项目中引入amis,状态管理方案
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 18.9k
- Forks
- 2.7k
- PR merge metrics
- No merged PRs in 30d
Description
#### 遇到的问题:
想请教下大家,在react应用中,引入了amis来编写页面组件,使用react-router进行页面跳转。页面代码使用amis 的schema进行配置的情况下,是如何做到多个page之间的页面通信的呢!我看到文档中有关于使用amisScoped.getComponentByName('page1').getValues()来获取页面内容的方法,但是每个页面都存在自己的amisScoped,是在调用renderAmis之后返回的,现在有A跟B两个页面,他们之间如何做到相互读取对方填写的页面数据呢!将每个页面的amisScoped存起来?
想了解下react中使用amis的情况下,各位是如果做状态管理的,还望不吝赐教🙏🙏🙏
:
请简单描述你现在遇到的不符合预期的问题...
#### 问题场景:
> A跟B分别有各自的路由,将来可能还有C,D页面,路由不断变化的过程中,是如何做到在不同页面中读取到其他页面产生的data的呢
```
const PageA = {
type: 'page',
name: 'pageA',
title: 'A页面',
body: [
{
type: 'form',
mode: 'horizontal',
title: '',
api: {
url: '/api/form/save',
},
actions: [
{
label: '保存',
type: 'submit',
},
],
body: [
{
label: '名字',
type: 'input-text',
name: 'name',
value: 'Aaron',
},
{
label: '年龄',
type: 'input-number',
name: 'age',
value: 10,
},
],
},
],
}
const PageB = {
type: 'page',
name: 'pageB',
title: 'B页面',
body: [
{
type: 'wrapper',
body: 'xxx', // 想展示PageA页面表单提交的的内容
},
],
}
```
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the React integration entry point, the amisScoped.getComponentByName('page1').getValues() documentation, and the renderAmis return value described in the issue. Reproduce the PageA and PageB route scenario and determine whether the project documents a supported cross-page state-management approach. Done would require an agreed scope and documented solution, since the issue currently asks for guidance rather than naming a code change.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- react, typescript
- Domain
- frontend
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 20/100