diff --git a/packages/amis-core/src/utils/replaceText.ts b/packages/amis-core/src/utils/replaceText.ts index 2df066994..b1c74d20b 100644 --- a/packages/amis-core/src/utils/replaceText.ts +++ b/packages/amis-core/src/utils/replaceText.ts @@ -6,8 +6,8 @@ import {isObject, JSONTraverse} from './helper'; export function replaceText( schema: any, - replaceText: {[propName: string]: string}, - replaceTextIgnoreKeys: String[] + replaceText?: {[propName: string]: string}, + replaceTextIgnoreKeys?: String[] ) { // 进行文本替换 if (replaceText && isObject(replaceText)) { diff --git a/packages/amis/src/renderers/App.tsx b/packages/amis/src/renderers/App.tsx index 1cbfa2191..a6c06bbce 100644 --- a/packages/amis/src/renderers/App.tsx +++ b/packages/amis/src/renderers/App.tsx @@ -1,7 +1,7 @@ import React from 'react'; import {AsideNav, Html, NotFound, Spinner} from 'amis-ui'; import {Layout} from 'amis-ui'; -import {Renderer, RendererProps} from 'amis-core'; +import {Renderer, RendererProps, replaceText} from 'amis-core'; import { BaseSchema, SchemaApi, @@ -197,6 +197,10 @@ export default class App extends React.Component { if (isEffectiveApi(api, store.data)) { const json = await store.fetchInitData(api, store.data, {}); + if (env.replaceText) { + replaceText(json.data, env.replaceText, env.replaceTextIgnoreKeys); + } + if (json?.data.pages) { store.setPages(json.data.pages); store.updateActivePage(env);