baidu / amis

前端低代码框架,通过 JSON 配置就能生成各种页面。
https://baidu.github.io/amis/
Apache License 2.0
17.11k stars 2.48k forks source link

导航组件`nav`点击会导致页面的刷新 #1791

Open fayeah opened 3 years ago

fayeah commented 3 years ago

描述问题:

期望通过导航栏跳转到某一个页面,但是对导航不应该使得页面整体刷新,效果应该跟Link功能一致。

截图或视频:

nav

如何复现(请务必完整填写下面内容):

  1. 你是如何使用 amis 的? amis@1.1.5+react-router-dom@5.2.0

  2. 粘贴有问题的完整 amis schema 代码:

    
    import React from "react";
    import {
    BrowserRouter as Router,
    Switch,
    Route,
    Link
    } from "react-router-dom";
    import {render as renderAmis, ToastComponent, AlertComponent} from 'amis';

const routes = [ { path: "/", exact: true, sidebar: () =>

home!
, main: () =>

Home

}, { path: "/bubblegum", sidebar: () =>
bubblegum!
, main: () =>

Bubblegum

}, { path: "/shoelaces", sidebar: () =>
shoelaces!
, main: () =>

Shoelaces

}, { path: "/404", sidebar: () =>
shoelaces!
, main: () =>
not found
} ];

const options = { "type": "page", "body": { "type": "nav", "stacked": true, "className": "w-md", "links": [ { "label": "Nav 1", "to": "/bubblegum", "icon": "https://suda.cdn.bcebos.com/images%2F2021-01%2Fdiamond.svg", }, { "label": "Nav 2", "to": "/shoelaces" }, { "label": "Nav 3", "to": "/404" } ] } }

export default function SidebarExample() { return (

{renderAmis(options)}
{routes.map((route, index) => ( } /> ))}

); }

lxdora commented 3 years ago

请问解决了吗?

fayeah commented 3 years ago

请问解决了吗?

么有,手写了一个nav

2betop commented 3 years ago

这个跟 env 里面的 jumpTo 实现有关

wuyudian1 commented 3 years ago

我也觉得这个设计极不合理,我希望的行为是:点击某个菜单后,只刷新 content 部分

xiaoxijin commented 2 years ago

@fayeah 请问,这个问题最终解决了么?

whuwangyong commented 1 year ago

同遇到这个问题。但是官网的demo看起来是只刷新了右边的content,不知道怎么做的。

demo: https://aisuda.bce.baidu.com/amis/examples/crud/aside2?cat=1