amis icon indicating copy to clipboard operation
amis copied to clipboard

nav渲染器如何切换不同页面

Open rudyxu1102 opened this issue 6 years ago • 12 comments

{
    "$schema": "https://houtai.baidu.com/v2/schemas/page.json#",
    "type": "page",
    "title": "",
    "aside": {
        "type": "wrapper",
        "size": "xs",
        "className": "",
        "body": {
            "type": "nav",
            "stacked": true,
            "links": [
                {
                    "label": "页面1",
                    "to": "?id=1"
                },
                {
                    "label": "页面2",
                    "children": [
                        {
                            "label": "页面2-1",
                            "to": "?id=2-1"
                        },
                        {
                            "label": "页面2-2",
                            "to": "?id=2-2"
                        },
                        {
                            "label": "页面2-3(disabled)",
                            "disabled": true,
                            "to": "?id=2-3"
                        }
                    ]
                },
                {
                    "label": "页面3",
                    "to": "?id=3"
                }
            ]
        }
    },
    "body": [
        {
            "type": "form",
            "title": "表单",
            "controls": [
                {
                    "label": "文本框",
                    "type": "text",
                    "name": "text"
                }
            ],
            "messages": {
                "fetchFailed": "初始化失败",
                "saveSuccess": "保存成功",
                "saveFailed": "保存失败"
            },
            "debug": false,
            "initApi": "",
            "visibleOn": "data.id == 1"
        }
    ],
    "messages": {},
    "initApi": {
        "method": "get",
        "url": "https://houtai.baidu.com/api/mock2/form/initData?id=${id}"
    }
}

image

"visibleOn": "data.id == 1"没有生效

要是能像tab渲染器一样就好了

rudyxu1102 avatar Dec 18 '19 07:12 rudyxu1102

你的意思是,需要添加 visibleOn disabledOn 功能呗?

2betop avatar Dec 18 '19 07:12 2betop

@2betop 我想点击不同的导航栏的时候,右侧显示不同的内容。现在在form里面设置的visibleOn没有生效,不知道怎么实现

rudyxu1102 avatar Dec 18 '19 07:12 rudyxu1102

我总感觉这是路由的事呢

2betop avatar Dec 18 '19 08:12 2betop

和我想做的那个单页应用差不多 后来我考虑用了service展示了 这样子的话 功能实现了 但是切换的时候状态就丢了

502647092 avatar Dec 18 '19 10:12 502647092

@502647092 service怎么实现的?可以贴下json吗 @2betop 如果是路由的话,怎么配置呢

rudyxu1102 avatar Dec 19 '19 01:12 rudyxu1102

路由不包含在 amis 里面呢。

2betop avatar Dec 19 '19 01:12 2betop

你这个栗子我放到 demo 里面跑是 ok 的,你是不是可能需要试试新版本?

2betop avatar Dec 19 '19 01:12 2betop

路由不包含在 amis 里面呢。

有需要为啥又不包含呢,如果用amis ,还得懂react router,那还用啥低代码哟

wuyudian1 avatar Jun 20 '21 12:06 wuyudian1

@wuyudian1 现在可以用APP模式渲染了 有路由功能

502647092 avatar Jun 21 '21 04:06 502647092

app 多页应用能多写点文档吗,文档太少,也没有完整示例,没整明白

wuyudian1 avatar Jun 27 '21 04:06 wuyudian1

感觉文档里很多地方的表达方式,都得专业前端才能看懂,这与项目的愿景不符啊

wuyudian1 avatar Jun 27 '21 04:06 wuyudian1

@wuyudian1 有解决方案吗,兄弟

user-huage avatar Sep 16 '21 02:09 user-huage