amis icon indicating copy to clipboard operation
amis copied to clipboard

amis渲染器配置schema从data数据域无法显示控件界面成功

Open wanghuapeng opened this issue 6 months ago • 1 comments

实现场景:

我想实现amis渲染器的schema从data数据域获取

存在的问题:

从数据域获取后,amis无法正确渲染

当前方案:

请粘贴你当前方案的完整 amis schema 代码... 以下两种代码都失败。

代码1-失败-使用对象:

{
  "type": "page",
  "data" : {
    "content" : {
      "type": "tpl",
      "tpl": "amis render"
    }
  },
  "body": {
    "type": "amis",
    "schema": "${content}"
  }
}

代码2-失败-使用json字符串,然后用表达式DECODEJSON转换成json对象

{
  "type": "page",
  "data" : {
    "content" : "{\"type\": \"tpl\",\"tpl\": \"amis render2\"}"
  },
  "body": {
    "type": "amis",
    "schema": "${DECODEJSON(content)}"
  }
}

代码3-成功-schema内联配置

{
  "type": "page",
  "body": {
    "type": "amis",
    "schema": {
      "type": "tpl",
      "tpl": "amis render"
    }
  }
}

只能内联的方式将content的内容直接放到schema属性上才能成功

wanghuapeng avatar Jun 19 '25 09:06 wanghuapeng

@wanghuapeng 你可以试试父组件为 form,or crud 类型

eminoda avatar Sep 22 '25 09:09 eminoda