From 735183f8c67d6d0d88f30b225cfbab8e469ea616 Mon Sep 17 00:00:00 2001 From: tangjinzhou <415800467@qq.com> Date: Sun, 26 Jul 2020 21:34:32 +0800 Subject: [PATCH] fix: breadcrumb paths not correct --- components/breadcrumb/Breadcrumb.jsx | 8 ++++---- .../__tests__/__snapshots__/Breadcrumb.test.js.snap | 11 ++++------- 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/components/breadcrumb/Breadcrumb.jsx b/components/breadcrumb/Breadcrumb.jsx index 106862e8f..934b6926c 100644 --- a/components/breadcrumb/Breadcrumb.jsx +++ b/components/breadcrumb/Breadcrumb.jsx @@ -1,4 +1,4 @@ -import { inject, cloneVNode, createVNode } from 'vue'; +import { inject, cloneVNode } from 'vue'; import PropTypes from '../_util/vue-types'; import { filterEmpty, getComponent, getSlot } from '../_util/props-util'; import warning from '../_util/warning'; @@ -71,6 +71,7 @@ export default { if (path) { paths.push(path); } + const tempPaths = [...paths]; // generated overlay by route.children let overlay = null; if (route.children && route.children.length) { @@ -82,8 +83,7 @@ export default { route: child, params, routes, - paths: this.addChildPath(paths, child.path, params), - h: createVNode, + paths: this.addChildPath(tempPaths, child.path, params), })} ))} @@ -97,7 +97,7 @@ export default { separator={separator} key={route.breadcrumbName || path} > - {itemRender({ route, params, routes, paths, h: createVNode })} + {itemRender({ route, params, routes, paths: tempPaths })} ); }); diff --git a/components/breadcrumb/__tests__/__snapshots__/Breadcrumb.test.js.snap b/components/breadcrumb/__tests__/__snapshots__/Breadcrumb.test.js.snap index 2a6d74522..e29d7e1e2 100644 --- a/components/breadcrumb/__tests__/__snapshots__/Breadcrumb.test.js.snap +++ b/components/breadcrumb/__tests__/__snapshots__/Breadcrumb.test.js.snap @@ -1,12 +1,9 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`Breadcrumb should allow Breadcrumb.Item is null or undefined 1`] = `
Home/
`; +exports[`Breadcrumb should allow Breadcrumb.Item is null or undefined 1`] = `
Home/
`; -exports[`Breadcrumb should not display Breadcrumb Item when its children is falsy 1`] = ` -
- xxx/yyy/
-`; +exports[`Breadcrumb should not display Breadcrumb Item when its children is falsy 1`] = `
/xxx/yyy/
`; -exports[`Breadcrumb should render a menu 1`] = `
home/first/second/
`; +exports[`Breadcrumb should render a menu 1`] = `
home/first/second/
`; -exports[`Breadcrumb should support custom attribute 1`] = `
xxx/yyy/
`; +exports[`Breadcrumb should support custom attribute 1`] = `
xxx/yyy/
`;