Merge branch 'feat-vue3' of https://github.com/vueComponent/ant-design-vue into feat-vue3

pull/2539/head
tanjinzhou 2020-07-07 14:19:17 +08:00
commit 469702da3e
5 changed files with 20 additions and 13 deletions

View File

@ -1,6 +1,6 @@
import isPlainObject from 'lodash/isPlainObject'; import isPlainObject from 'lodash/isPlainObject';
import classNames from 'classnames'; import classNames from 'classnames';
import { isVNode, Fragment, Comment, Text } from 'vue'; import { isVNode, Fragment, Comment, Text, h } from 'vue';
import { camelize, hyphenate, isOn, resolvePropValue } from './util'; import { camelize, hyphenate, isOn, resolvePropValue } from './util';
import isValid from './isValid'; import isValid from './isValid';
// function getType(fn) { // function getType(fn) {
@ -187,7 +187,7 @@ const getComponent = (instance, prop = 'default', options = instance, execute =
}; };
const getComponentFromProp = (instance, prop, options = instance, execute = true) => { const getComponentFromProp = (instance, prop, options = instance, execute = true) => {
if (instance.$createElement) { if (instance.$createElement) {
const h = instance.$createElement; // const h = instance.$createElement;
const temp = instance[prop]; const temp = instance[prop];
if (temp !== undefined) { if (temp !== undefined) {
return typeof temp === 'function' && execute ? temp(h, options) : temp; return typeof temp === 'function' && execute ? temp(h, options) : temp;
@ -199,7 +199,7 @@ const getComponentFromProp = (instance, prop, options = instance, execute = true
undefined undefined
); );
} else { } else {
const h = instance.context.$createElement; // const h = instance.context.$createElement;
const temp = getPropsData(instance)[prop]; const temp = getPropsData(instance)[prop];
if (temp !== undefined) { if (temp !== undefined) {
return typeof temp === 'function' && execute ? temp(h, options) : temp; return typeof temp === 'function' && execute ? temp(h, options) : temp;

View File

@ -12,6 +12,7 @@ import { cloneElement } from '../_util/vnode';
import getTransitionProps from '../_util/getTransitionProps'; import getTransitionProps from '../_util/getTransitionProps';
import isNumeric from '../_util/isNumeric'; import isNumeric from '../_util/isNumeric';
import { ConfigConsumerProps } from '../config-provider'; import { ConfigConsumerProps } from '../config-provider';
import { inject } from 'vue';
const BadgeProps = { const BadgeProps = {
/** Number to show in badge */ /** Number to show in badge */
@ -40,8 +41,10 @@ export default {
dot: false, dot: false,
overflowCount: 99, overflowCount: 99,
}), }),
inject: { setup() {
configProvider: { default: () => ConfigConsumerProps }, return {
configProvider: inject('configProvider', ConfigConsumerProps),
};
}, },
methods: { methods: {
getNumberedDispayCount() { getNumberedDispayCount() {
@ -80,7 +83,7 @@ export default {
: { ...numberStyle }; : { ...numberStyle };
}, },
getBadgeClassName(prefixCls) { getBadgeClassName(prefixCls) {
const children = filterEmpty(this.$slots.default); const children = filterEmpty(this.$slots.default && this.$slots.default());
const hasStatus = this.hasStatus(); const hasStatus = this.hasStatus();
return classNames(prefixCls, { return classNames(prefixCls, {
[`${prefixCls}-status`]: hasStatus, [`${prefixCls}-status`]: hasStatus,
@ -181,7 +184,7 @@ export default {
const prefixCls = getPrefixCls('badge', customizePrefixCls); const prefixCls = getPrefixCls('badge', customizePrefixCls);
const scrollNumberPrefixCls = getPrefixCls('scroll-number', customizeScrollNumberPrefixCls); const scrollNumberPrefixCls = getPrefixCls('scroll-number', customizeScrollNumberPrefixCls);
const children = filterEmpty($slots.default); const children = filterEmpty($slots.default && $slots.default());
let count = getComponentFromProp(this, 'count'); let count = getComponentFromProp(this, 'count');
if (Array.isArray(count)) { if (Array.isArray(count)) {
count = count[0]; count = count[0];

View File

@ -5,6 +5,7 @@ import { getStyle } from '../_util/props-util';
import omit from 'omit.js'; import omit from 'omit.js';
import { cloneElement } from '../_util/vnode'; import { cloneElement } from '../_util/vnode';
import { ConfigConsumerProps } from '../config-provider'; import { ConfigConsumerProps } from '../config-provider';
import { inject } from 'vue';
function getNumberArray(num) { function getNumberArray(num) {
return num return num
@ -31,8 +32,10 @@ const ScrollNumberProps = {
export default { export default {
mixins: [BaseMixin], mixins: [BaseMixin],
props: ScrollNumberProps, props: ScrollNumberProps,
inject: { setup() {
configProvider: { default: () => ConfigConsumerProps }, return {
configProvider: inject('configProvider', ConfigConsumerProps),
};
}, },
data() { data() {
return { return {

View File

@ -1,10 +1,8 @@
import Badge from './Badge'; import Badge from './Badge';
import Base from '../base';
/* istanbul ignore next */ /* istanbul ignore next */
Badge.install = function(Vue) { Badge.install = function(app) {
Vue.use(Base); app.component(Badge.name, Badge);
Vue.component(Badge.name, Badge);
}; };
export default Badge; export default Badge;

View File

@ -2,6 +2,7 @@ import '@babel/polyfill';
import { createApp } from 'vue'; import { createApp } from 'vue';
import App from './App.vue'; import App from './App.vue';
import { import {
Badge,
AutoComplete, AutoComplete,
Radio, Radio,
Spin, Spin,
@ -23,6 +24,7 @@ import {
notification, notification,
message, message,
} from 'ant-design-vue'; } from 'ant-design-vue';
import 'ant-design-vue/style.js'; import 'ant-design-vue/style.js';
const basic = { const basic = {
@ -51,6 +53,7 @@ app
.use(Tooltip) .use(Tooltip)
.use(Col) .use(Col)
.use(Row) .use(Row)
.use(Badge)
.use(Radio) .use(Radio)
.use(Switch) .use(Switch)
.use(Checkbox) .use(Checkbox)