From 30b24fcad7365c26407393c159cbafd3f603b51e Mon Sep 17 00:00:00 2001 From: xrkffgg Date: Sat, 6 Jun 2020 14:30:47 +0800 Subject: [PATCH] feat: ipdate skeleton --- components/skeleton/index.jsx | 15 ++++++++------- examples/index.js | 2 ++ 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/components/skeleton/index.jsx b/components/skeleton/index.jsx index c66bdbde35..6a9dea63c3 100644 --- a/components/skeleton/index.jsx +++ b/components/skeleton/index.jsx @@ -1,3 +1,4 @@ +import { inject } from 'vue'; import classNames from 'classnames'; import PropTypes from '../_util/vue-types'; import { initDefaultProps, hasProp } from '../_util/props-util'; @@ -5,7 +6,6 @@ import { ConfigConsumerProps } from '../config-provider'; import Avatar, { SkeletonAvatarProps } from './Avatar'; import Title, { SkeletonTitleProps } from './Title'; import Paragraph, { SkeletonParagraphProps } from './Paragraph'; -import Base from '../base'; export const SkeletonProps = { active: PropTypes.bool, @@ -69,8 +69,10 @@ const Skeleton = { title: true, paragraph: true, }), - inject: { - configProvider: { default: () => ConfigConsumerProps }, + setup() { + return { + configProvider: inject('configProvider', ConfigConsumerProps), + }; }, render() { const { @@ -157,13 +159,12 @@ const Skeleton = { ); } - const children = this.$slots.default; + const children = this.$slots.default && this.$slots.default(); return children && children.length === 1 ? children[0] : {children}; }, }; /* istanbul ignore next */ -Skeleton.install = function(Vue) { - Vue.use(Base); - Vue.component(Skeleton.name, Skeleton); +Skeleton.install = function(app) { + app.component(Skeleton.name, Skeleton); }; export default Skeleton; diff --git a/examples/index.js b/examples/index.js index 496092d97f..46e31cb350 100644 --- a/examples/index.js +++ b/examples/index.js @@ -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 Skeleton from 'ant-design-vue/skeleton'; import Empty from 'ant-design-vue/empty'; import Timeline from 'ant-design-vue/timeline'; import 'ant-design-vue/style.js'; @@ -27,6 +28,7 @@ createApp(App) .use(Divider) .use(Result) .use(Anchor) + .use(Skeleton) .use(Spin) .use(Empty) .use(Timeline)