Skip to content

feat: update pageheader #2365

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jun 8, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 17 additions & 16 deletions components/page-header/index.jsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { inject } from 'vue';
import PropTypes from '../_util/vue-types';
import { getComponentFromProp, getOptionProps } from '../_util/props-util';
import { getComponent, getOptionProps } from '../_util/props-util';
import { ConfigConsumerProps } from '../config-provider';
import ArrowLeftOutlined from '@ant-design/icons-vue/ArrowLeftOutlined';
import Breadcrumb from '../breadcrumb';
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

不知道为啥报一个 breadcrumb 相关的错

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

./components/breadcrumb/Breadcrumb.jsx
Cannot read property 'includes' of undefined

一直报这个错 @tangjinzhou

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

因为有 <Xxx.Xxx /> 的使用方式 @Amour1688 插件不支持

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

插件 bug,本周发版修复

import Avatar from '../avatar';
import TransButton from '../_util/transButton';
import LocaleReceiver from '../locale-provider/LocaleReceiver';
import Base from '../base';

export const PageHeaderProps = {
backIcon: PropTypes.any,
Expand Down Expand Up @@ -52,17 +52,17 @@ const renderBreadcrumb = (h, breadcrumb) => {

const renderTitle = (h, prefixCls, instance) => {
const { avatar } = instance;
const title = getComponentFromProp(instance, 'title');
const subTitle = getComponentFromProp(instance, 'subTitle');
const tags = getComponentFromProp(instance, 'tags');
const extra = getComponentFromProp(instance, 'extra');
const title = getComponent(instance, 'title');
const subTitle = getComponent(instance, 'subTitle');
const tags = getComponent(instance, 'tags');
const extra = getComponent(instance, 'extra');
const backIcon =
getComponentFromProp(instance, 'backIcon') !== undefined ? (
getComponentFromProp(instance, 'backIcon')
getComponent(instance, 'backIcon') !== undefined ? (
getComponent(instance, 'backIcon')
) : (
<ArrowLeftOutlined />
);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

const onBack = instance.$listeners.back;
to
const onBack = instance.$attrs.onBack;

const onBack = instance.$listeners.back;
const onBack = instance.$attrs.onBack;
const headingPrefixCls = `${prefixCls}-heading`;
if (title || subTitle || tags || extra) {
const backIconDom = renderBack(instance, prefixCls, backIcon, onBack);
Expand Down Expand Up @@ -94,15 +94,17 @@ const renderChildren = (h, prefixCls, children) => {
const PageHeader = {
name: 'APageHeader',
props: PageHeaderProps,
inject: {
configProvider: { default: () => ConfigConsumerProps },
setup() {
return {
configProvider: inject('configProvider', ConfigConsumerProps),
};
},
render(h) {
const { getPrefixCls, pageHeader } = this.configProvider;
const props = getOptionProps(this);
const { prefixCls: customizePrefixCls, breadcrumb } = props;
const footer = getComponentFromProp(this, 'footer');
const children = this.$slots.default;
const footer = getComponent(this, 'footer');
const children = this.$slots.default && this.$slots.default();

let ghost = true;

Expand Down Expand Up @@ -138,9 +140,8 @@ const PageHeader = {
};

/* istanbul ignore next */
PageHeader.install = function(Vue) {
Vue.use(Base);
Vue.component(PageHeader.name, PageHeader);
PageHeader.install = function(app) {
app.component(PageHeader.name, PageHeader);
};

export default PageHeader;
2 changes: 2 additions & 0 deletions examples/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import Anchor from 'ant-design-vue/anchor';
import ConfigProvider from 'ant-design-vue/config-provider';
import Result from 'ant-design-vue/result';
import Spin from 'ant-design-vue/spin';
import PageHeader from 'ant-design-vue/page-header';
import Skeleton from 'ant-design-vue/skeleton';
import Empty from 'ant-design-vue/empty';
import Timeline from 'ant-design-vue/timeline';
Expand All @@ -27,6 +28,7 @@ createApp(App)
.use(Alert)
.use(Divider)
.use(Result)
.use(PageHeader)
.use(Anchor)
.use(Skeleton)
.use(Spin)
Expand Down