mirror of
https://gitee.com/baidu/amis.git
synced 2024-12-01 19:38:16 +08:00
Merge pull request #7164 from 2betop/chore-jssdk
feat: JSSDK 支持更新 schema Close: #7150
This commit is contained in:
commit
6a0df22514
@ -236,6 +236,34 @@ amisScoped.updateProps(
|
||||
);
|
||||
```
|
||||
|
||||
### 更新配置
|
||||
|
||||
可以通过 amisScoped 对象的 udpateSchema 方法来更新更新内容配置。
|
||||
|
||||
```js
|
||||
let amisJSON = {
|
||||
type: 'page',
|
||||
body: [
|
||||
'inital string',
|
||||
|
||||
{
|
||||
type: 'button',
|
||||
label: 'Change',
|
||||
onClick: handleChange
|
||||
}
|
||||
]
|
||||
};
|
||||
let amisScoped = amis.embed('#root', amisJSON);
|
||||
|
||||
function handleChange() {
|
||||
const schema = {
|
||||
...amisJSON,
|
||||
body: ['changed']
|
||||
};
|
||||
amisScoped.updateSchema(schema);
|
||||
}
|
||||
```
|
||||
|
||||
### 多页模式
|
||||
|
||||
默认 amis 渲染是单页模式,如果想实现多页应用,请使用 [app 渲染器](../../components/app)。
|
||||
|
@ -295,6 +295,10 @@ export function embed(
|
||||
updateProps: (props: any, callback?: () => void) => {
|
||||
root.render(createElements(props));
|
||||
},
|
||||
updateSchema: (newSchema: any, props = {}) => {
|
||||
schema = newSchema;
|
||||
root.render(createElements(props));
|
||||
},
|
||||
unmount: () => {
|
||||
root.unmount();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user