Skip to content

Commit de834ce

Browse files
authored
feat: update spin (#2351)
1 parent 5417d92 commit de834ce

File tree

3 files changed

+13
-11
lines changed

3 files changed

+13
-11
lines changed

components/spin/Spin.jsx

+9-7
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1+
import { inject, cloneVNode } from 'vue';
12
import debounce from 'lodash/debounce';
23
import PropTypes from '../_util/vue-types';
34
import BaseMixin from '../_util/BaseMixin';
45
import {
56
filterEmpty,
67
initDefaultProps,
78
isValidElement,
8-
getComponentFromProp,
9+
getComponent,
910
getListeners,
1011
} from '../_util/props-util';
11-
import { cloneElement } from '../_util/vnode';
1212
import { ConfigConsumerProps } from '../config-provider';
1313

1414
export const SpinSize = PropTypes.oneOf(['small', 'default', 'large']);
@@ -47,8 +47,10 @@ export default {
4747
spinning: true,
4848
wrapperClassName: '',
4949
}),
50-
inject: {
51-
configProvider: { default: () => ConfigConsumerProps },
50+
setup() {
51+
return {
52+
configProvider: inject('configProvider', ConfigConsumerProps),
53+
};
5254
},
5355
data() {
5456
const { spinning, delay } = this;
@@ -100,7 +102,7 @@ export default {
100102
renderIndicator(h, prefixCls) {
101103
// const h = this.$createElement
102104
const dotClassName = `${prefixCls}-dot`;
103-
let indicator = getComponentFromProp(this, 'indicator');
105+
let indicator = getComponent(this, 'indicator');
104106
// should not be render default indicator when indicator value is null
105107
if (indicator === null) {
106108
return null;
@@ -110,11 +112,11 @@ export default {
110112
indicator = indicator.length === 1 ? indicator[0] : indicator;
111113
}
112114
if (isValidElement(indicator)) {
113-
return cloneElement(indicator, { class: dotClassName });
115+
return cloneVNode(indicator, { class: dotClassName });
114116
}
115117

116118
if (defaultIndicator && isValidElement(defaultIndicator(h))) {
117-
return cloneElement(defaultIndicator(h), { class: dotClassName });
119+
return cloneVNode(defaultIndicator(h), { class: dotClassName });
118120
}
119121

120122
return (

components/spin/index.js

+2-4
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
11
import Spin, { setDefaultIndicator } from './Spin';
2-
import Base from '../base';
32

43
export { SpinProps } from './Spin';
54

65
Spin.setDefaultIndicator = setDefaultIndicator;
76

87
/* istanbul ignore next */
9-
Spin.install = function(Vue) {
10-
Vue.use(Base);
11-
Vue.component(Spin.name, Spin);
8+
Spin.install = function(app) {
9+
app.component(Spin.name, Spin);
1210
};
1311

1412
export default Spin;

examples/index.js

+2
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import Drawer from 'ant-design-vue/drawer';
66
import Affix from 'ant-design-vue/affix';
77
import Alert from 'ant-design-vue/alert';
88
import ConfigProvider from 'ant-design-vue/config-provider';
9+
import Spin from 'ant-design-vue/Spin';
910
import 'ant-design-vue/style.js';
1011

1112
createApp(App)
@@ -14,4 +15,5 @@ createApp(App)
1415
.use(Drawer)
1516
.use(Affix)
1617
.use(Alert)
18+
.use(Spin)
1719
.mount('#app');

0 commit comments

Comments
 (0)