提交 067d8726 编写于 作者: D DCloud_LXH

fix(H5): Navigator add properties to control SSR rendering question/162590

上级 a1c728c8
import { getCurrentInstance } from 'vue'
import { extend } from '@vue/shared'
import { defineBuiltInComponent } from '@dcloudio/uni-components'
import { onEventPrevent } from '@dcloudio/uni-core'
......@@ -14,7 +15,12 @@ export default /*#__PURE__*/ defineBuiltInComponent({
compatConfig: {
MODE: 3,
},
props: navigatorProps,
props: extend({}, navigatorProps, {
ssr: {
type: Boolean,
default: true,
},
}),
setup(props, { slots }) {
const vm = getCurrentInstance()
const __scopeId = (vm && vm.vnode.scopeId) || ''
......@@ -26,25 +32,31 @@ export default /*#__PURE__*/ defineBuiltInComponent({
const { hoverClass, url } = props
const hasHoverClass = props.hoverClass && props.hoverClass !== 'none'
return (
const navigatorTsx = (
<uni-navigator
class={hasHoverClass && hovering.value ? hoverClass : ''}
{...(hasHoverClass && binding)}
{...(vm ? vm.attrs : {})}
{...{
[__scopeId]: '',
}}
onClick={onClick}
>
{slots.default && slots.default()}
</uni-navigator>
)
return props.ssr ? (
<a
class="navigator-wrap"
href={url}
onClick={onEventPrevent}
onMousedown={onEventPrevent}
>
<uni-navigator
class={hasHoverClass && hovering.value ? hoverClass : ''}
{...(hasHoverClass && binding)}
{...(vm ? vm.attrs : {})}
{...{
[__scopeId]: '',
}}
onClick={onClick}
>
{slots.default && slots.default()}
</uni-navigator>
{navigatorTsx}
</a>
) : (
navigatorTsx
)
}
},
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册