From 683cb341e3cc12d7ffe3fdcc052cf99620d2527c Mon Sep 17 00:00:00 2001 From: DCloud_LXH <283700113@qq.com> Date: Fri, 7 Jan 2022 18:13:46 +0800 Subject: [PATCH] fix(ssr): navigator --- .../src/components/navigator/index.tsx | 37 +++++++++++++++---- 1 file changed, 30 insertions(+), 7 deletions(-) diff --git a/packages/uni-components/src/components/navigator/index.tsx b/packages/uni-components/src/components/navigator/index.tsx index fc28dfb24..4be5b0ad6 100644 --- a/packages/uni-components/src/components/navigator/index.tsx +++ b/packages/uni-components/src/components/navigator/index.tsx @@ -1,5 +1,7 @@ +import { getCurrentInstance } from 'vue' import { useHover } from '../../helpers/useHover' import { defineBuiltInComponent } from '@dcloudio/uni-components' +import { useAttrs } from '../../helpers/useAttrs' const OPEN_TYPES = [ 'navigate', @@ -49,11 +51,17 @@ const props = { export default /*#__PURE__*/ defineBuiltInComponent({ name: 'Navigator', + inheritAttrs: false, compatConfig: { MODE: 3, }, props, setup(props, { slots }) { + const vm = getCurrentInstance() + const __scopeId = (vm?.root?.type as any).__scopeId || '' + const { $attrs, $excludeAttrs, $listeners } = useAttrs({ + excludeListeners: true, + }) const { hovering, binding } = useHover(props) function onClick($event: MouseEvent) { @@ -98,16 +106,31 @@ export default /*#__PURE__*/ defineBuiltInComponent({ } return () => { - const { hoverClass } = props + const { hoverClass, url } = props const hasHoverClass = props.hoverClass && props.hoverClass !== 'none' return ( - { + e.preventDefault() + return false + }} + style={{ 'text-decoration': 'none' }} + {...$listeners.value} > - {slots.default && slots.default()} - + + {slots.default && slots.default()} + + ) } }, -- GitLab