Merge pull request #7164 from 2betop/chore-jssdk

feat: JSSDK 支持更新 schema Close: #7150
This commit is contained in:
hsm-lv 2023-06-16 13:24:12 +08:00 committed by GitHub
commit 6a0df22514
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 32 additions and 0 deletions

View File

@ -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)。

View File

@ -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();
}