Commit 17a96398 authored by Sendya's avatar Sendya

fix: prop back and event @back check

parent ca83d764
...@@ -6,12 +6,8 @@ ...@@ -6,12 +6,8 @@
this.tabActiveKey = key this.tabActiveKey = key
console.log('PageHeader::tabChange', key) console.log('PageHeader::tabChange', key)
}" }"
@back="() => { @back="(e) => {
console.log('PageHeader::@back') console.log('PageHeader::back', e)
}"
:back="() => {
// 自定义 back,不会覆盖 onBack 事件
console.log('PageHeader::.back')
}" }"
:breadcrumb="customBreadcrumb" :breadcrumb="customBreadcrumb"
> >
......
...@@ -113,7 +113,6 @@ const defaultPageHeaderRender = (h, props, pageMeta, i18nRender) => { ...@@ -113,7 +113,6 @@ const defaultPageHeaderRender = (h, props, pageMeta, i18nRender) => {
breadcrumb, breadcrumb,
extra, extra,
title: i18nRender(pageHeaderTitle), title: i18nRender(pageHeaderTitle),
onBack: handleBack || noop,
footer: renderFooter(h, restProps, i18nRender), footer: renderFooter(h, restProps, i18nRender),
} }
if (!handleBack) { if (!handleBack) {
...@@ -121,7 +120,7 @@ const defaultPageHeaderRender = (h, props, pageMeta, i18nRender) => { ...@@ -121,7 +120,7 @@ const defaultPageHeaderRender = (h, props, pageMeta, i18nRender) => {
} }
return ( return (
<PageHeader {...{ props: tabProps }}> <PageHeader {...{ props: tabProps }} onBack={handleBack || noop}>
{renderPageHeader(h, content, extraContent)} {renderPageHeader(h, content, extraContent)}
</PageHeader> </PageHeader>
) )
...@@ -133,7 +132,7 @@ const PageHeaderWrapper = { ...@@ -133,7 +132,7 @@ const PageHeaderWrapper = {
props: PageHeaderWrapperProps, props: PageHeaderWrapperProps,
inject: ['locale', 'contentWidth', 'breadcrumbRender'], inject: ['locale', 'contentWidth', 'breadcrumbRender'],
render(h) { render(h) {
const { $route } = this const { $route, $listeners } = this
const children = this.$slots.default const children = this.$slots.default
const content = getComponentFromProp(this, 'content') const content = getComponentFromProp(this, 'content')
const extra = getComponentFromProp(this, 'extra') const extra = getComponentFromProp(this, 'extra')
...@@ -143,9 +142,10 @@ const PageHeaderWrapper = { ...@@ -143,9 +142,10 @@ const PageHeaderWrapper = {
const i18n = this.$props.i18nRender || this.locale || defaultI18nRender const i18n = this.$props.i18nRender || this.locale || defaultI18nRender
const contentWidth = this.$props.contentWidth || this.contentWidth || false const contentWidth = this.$props.contentWidth || this.contentWidth || false
// 当未设置 back props 或未监听 @back,不显示 back // 当未设置 back props 或未监听 @back,不显示 back
const onBack = this.$props.back // props 的 back 事件优先级高于 @back,需要注意
const onBack = this.$props.back || $listeners.back
const back = onBack && (() => { const back = onBack && (() => {
this.$emit('back') // this.$emit('back')
// call props back func // call props back func
onBack && onBack() onBack && onBack()
}) || undefined }) || undefined
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment