Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

导航Nav组件实现click高亮过程遇到小问题,求赐教 #9991

Closed
FirthTuckman opened this issue Apr 10, 2024 · 2 comments
Closed
Assignees

Comments

@FirthTuckman
Copy link

实现场景:

想实现导航菜单click时被点击菜单高亮

存在的问题:

curNav在click事件中可以被修改,但导航组件没有更新,尝试了trackExpression: '${curNav}'也不行,刚上手,不太熟,请赐教

当前方案:

请粘贴你当前方案的完整 amis schema 代码...

{
                type: 'service',
                data: {
                    curNav: '概览',
                },
                body: [{
                    type: 'nav',
                    trackExpression: '${curNav}',
                    links: [{
                            "label": "概览",
                            "activeOn": "${curNav == '概览'}"
                        },
                        {
                            "label": "门户管理",
                            "children": [{
                                    "label": "栏目管理",
                                    "activeOn": "${curNav == '栏目管理'}"
                                },
                                {
                                    "label": "内容管理",
                                    "activeOn": "${curNav == '内容管理'}"
                                },
                            ],
                        },
                    ],
                    onEvent: {
                        click: {
                            actions: [{
                                "actionType": "custom",
                                "script": "curNav = event.data.item.label; console.log(curNav);",
                            }],
                        },
                    },
                }, ],
            },

@FirthTuckman
Copy link
Author

很困惑,为什么在click事件中已经更新了curNav,但是组件中的activeOn表达式不重新计算? 是需要trackExpression吗,trackExpression: '${curNav}', 这样写为什么不生效?

@FirthTuckman
Copy link
Author

坑死了!!已被6.3版本Fix:#9829

@qkiroc qkiroc closed this as completed Apr 10, 2024
@qkiroc qkiroc self-assigned this Apr 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants