amis 地址栏携带的参数,无法自动填充到组件里面

vm0i2vca  于 4个月前  发布在  其他
关注(0)|答案(6)|浏览(50)
描述问题:

地址栏携带的参数,无法自动填充到组件里面

截图或视频:

如何复现(请务必完整填写下面内容):
  1. 你是如何使用 amis 的?
    使用sdk的方式引入 3.4.3版本
  2. amis 版本是什么?请先在最新 beta 版本测试问题是否存在

3.4.0 这个版本还不存在这个问题,从3.4.2就存在这个问题了

  1. 粘贴有问题的完整 amis schema 代码:
AMIS_JSON={
    "type": "page",
    "definitions":{
        "jsonForm":{
            "title": "json-${name}",
            "size": "full",
            "body": {
                "type": "form",
                "initApi": "/admin/form/getJson?id=${id}",
                "api": "/admin/form/saveJson",
                "actions":[],
                "body": [
                    {
                        "type": "editor",
                        "name": "json",
                        "size":"xxl",
                        "language": "json",
                        "disabled": false,
                        "allowFullscreen":true
                    }
                ]
            }
        }
    },
    "body": {
        "type": "crud",
        "api": "post:/admin/form/query",
        "syncLocation": false,
        "filterTogglable": false,
        "affixHeader":true,
        "autoFillHeight": true,
        "headerToolbar": [
            "filter-toggler",{
                "label": "新增",
                "type": "button",
                "primary": true,
                "actionType": "dialog",
                "dialog": {
                    "title":"新增",
                    "size":"full",
                    "body":{
                        "type":"iframe",
                        "src":"/admin/page/formEdit.html",
                        "height":"calc( 100% - 10px )"
                    },
                    "actions":[]
                }
            },
            {
                "type": "button",
                "actionType": "dialog",
                "label": "JSON新增",
                "size":"sm",
                "icon": "fa fa-plus pull-left",
                "primary": true,
                "dialog":{
                    "$ref":"jsonForm"
                }
            }
        ],
        "filter": {
            "title":["<span style='line-height:30px;'>表单管理</span>"
                /*,{
                    "type":"button",
                    "label":"刷新页面",
                    "actionType": "url",
                    "url":"",
                    "blank":false,
                    "level":"secondary",
                    "className":"m-l float-right relative jqp-top-btn"
                }*/],
            "submitText": "",
            "mode": "horizontal",
            "body": [
                {
                    "type":"grid",
                    "columns":[{
                        "type": "input-text",
                        "name": "code",
                        "label":"编号"
                    },
                    {
                        "type": "input-text",
                        "name": "name",
                        "label":"名称"
                    },{
                        "label": "查询",
                        "primary":true,
                        "type": "submit"
                    }]
                }
            ]
        },
        "columns": [
            {
                "name": "code",
                "label": "编号"
            },
            {
                "name": "name",
                "label": "名称"
            },
            {
                "name": "tableName",
                "label": "表"
            },
            {
                "name": "js",
                "label": "js脚本"
            },
            {
                "type": "operation",
                "label": "操作",
                "buttons": [
                    {
                        "label": "编辑",
                        "type": "button",
                        "actionType": "dialog",
                        "dialog": {
                            "title":"编辑-${name}",
                            "size":"full",
                            "body":{
                                "type":"iframe",
                                "src":"/admin/page/formEdit.html?id=${id}",
                                "height":"calc( 100% - 10px )"
                            },
                            "actions":[]
                        }
                    },{
                        "label": "复制",
                        "type": "button",
                        "actionType": "dialog",
                        "dialog": {
                            "title":"复制-${name}",
                            "size":"full",
                            "body":{
                                "type":"iframe",
                                "src":"/admin/page/formEdit.html?id=${id}&type=copy",
                                "height":"calc( 100% - 10px )"
                            },
                            "actions":[]
                        }
                    },{
                        "label": "预览",
                        "type": "button",
                        "actionType": "url",
                        "url":"/form/${code}"
                    },{
                        "label": "预览js",
                        "type": "button",
                        "actionType": "url",
                        "url":"/admin/form/js/${code}.js"
                    },{
                        "type": "button",
                        "level":"danger",
                        "actionType": "ajax",
                        "label": "删除",
                        "confirmText": "您确认要删除${name}?",
                        "api": "/admin/common/form/delete/${id}"
                    },{
                        "label": "编辑JSON",
                        "type": "button",
                        "actionType": "dialog",
                        "dialog": {
                            "$ref":"jsonForm"
                        }
                    }
                ]
            }
            /*,{
                "type":"each",
                "label":"循环",
                "name":"buttons",
                "className":"antd-OperationField",
                "items":{
                    "type":"button",
                    "size":"sm",
                    "label":"${name}",
                    "actionType": "ajax",
                    "api":"/xxxx.xxx"
                }
            }
            */
        ]
    }
}
  1. 操作步骤
    浏览器访问此页面,携带 参数 ?code=test ,crud的查询表单里面名称为code的input无法带入此参数
mkh04yzy

mkh04yzy1#

👍 Thanks for this!
🏷 I have applied any labels matching special text in your issue.

Please review the labels and make any necessary changes.

gkl3eglg

gkl3eglg2#

为啥这问题一直没人解决

cwdobuhd

cwdobuhd3#

应该把同步地址栏打开?

yiytaume

yiytaume4#

根据官方文档,url里面的参数为顶级数据域,3.4.3 之前都是没问题的,由于这个问题,我一直无法更新到最新版本

https://aisuda.bce.baidu.com/amis/zh-CN/docs/concepts/datascope-and-datachain#url-%E5%8F%82%E6%95%B0?word=myquery&page=1

ma8fv8wu

ma8fv8wu5#

应该把同步地址栏打开?

syncLocation 设置为true解决了

之前的版本syncLocation,这个我设置为false,没问题,现在必须要设置为true,而且把其他参数都放到地址栏了,实际上其他参数不需要同步到地址栏

unhi4e5o

unhi4e5o6#

应该把同步地址栏打开?

syncLocation 设置为true解决了

之前的版本syncLocation,这个我设置为false,没问题,现在必须要设置为true,而且把其他参数都放到地址栏了,实际上其他参数不需要同步到地址栏

这有问题,当查询参数变化后,会刷新整个页面,数据作用域乱套了,另外在列表的弹出层里面,点击打开弹出层后,有些按钮的表达式并没有执行

在保存后才会执行,但是这个问题在之前的版本都是没有的

相关问题