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

请问一下,这个有办法动态生成路由吗? #7

Closed
taoyao-code opened this issue Jul 5, 2022 · 4 comments
Closed

请问一下,这个有办法动态生成路由吗? #7

taoyao-code opened this issue Jul 5, 2022 · 4 comments

Comments

@taoyao-code
Copy link

现在的情况是直接就加载了全部,写在前端的json数据,请问有什么办法通过后端获取json数据进行渲染吗?

@iceqing
Copy link
Owner

iceqing commented Jul 5, 2022

你的意思是不是通过接口获取动态的菜单?目前api/menus这个接口本地是被mock的,可以直接替换为后端的接口,演示网站就是从接口获取的动态菜单。

演示网站地址

@taoyao-code
Copy link
Author

是这样的,比如说,通过菜单的路径参数进行请求获取数据,然后动态显示这里的数据
image
,而不是在前端写成固定的文件。
点击不同的菜单,请求,然后返回不同的数据进行展示
image

@iceqing
Copy link
Owner

iceqing commented Jul 6, 2022

可以的,amis提供了schemaApi功能,可以从远端拉取amis json来生成界面,如果想渲染不同的界面,可以给schemaApi指定下参数,后端接口根据参数返回不同的json即可。

已经在master 分支提供了示例,可以试下:

image

@taoyao-code
Copy link
Author

好的,谢谢。

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