diff --git a/docs/zh-CN/start/getting-started.md b/docs/zh-CN/start/getting-started.md index 9ef0a376d..6cd722747 100644 --- a/docs/zh-CN/start/getting-started.md +++ b/docs/zh-CN/start/getting-started.md @@ -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)。 diff --git a/examples/embed.tsx b/examples/embed.tsx index da5792aa0..56a6a5fd8 100644 --- a/examples/embed.tsx +++ b/examples/embed.tsx @@ -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(); }