fix: update button

pull/2324/head
tangjinzhou 2020-05-28 23:36:43 +08:00
parent 242b5a3d99
commit ec4d6597d1
5 changed files with 32 additions and 26 deletions

@ -1 +1 @@
Subproject commit f3b049411f17e556d8795f40d41bfadb471ae630
Subproject commit adbfcd30aeb6c125defa35102ed659f1be03c672

View File

@ -1,4 +1,5 @@
import { filterEmpty } from '../_util/props-util';
import { inject } from 'vue';
import { filterEmpty, getSlot } from '../_util/props-util';
import PropTypes from '../_util/vue-types';
import { ConfigConsumerProps } from '../config-provider';
@ -14,8 +15,11 @@ export { ButtonGroupProps };
export default {
name: 'AButtonGroup',
props: ButtonGroupProps,
inject: {
configProvider: { default: () => ConfigConsumerProps },
setup() {
const configProvider = inject('configProvider') || ConfigConsumerProps;
return {
configProvider,
};
},
data() {
return {
@ -26,7 +30,7 @@ export default {
};
},
render() {
const { prefixCls: customizePrefixCls, size, $slots } = this;
const { prefixCls: customizePrefixCls, size } = this;
const getPrefixCls = this.configProvider.getPrefixCls;
const prefixCls = getPrefixCls('btn-group', customizePrefixCls);
@ -47,6 +51,6 @@ export default {
[`${prefixCls}`]: true,
[`${prefixCls}-${sizeCls}`]: sizeCls,
};
return <div class={classes}>{filterEmpty($slots.default)}</div>;
return <div class={classes}>{filterEmpty(getSlot(this))}</div>;
},
};

View File

@ -69,7 +69,7 @@ export default {
$slots,
$attrs,
} = this;
const getPrefixCls = this.configProvider().getPrefixCls;
const getPrefixCls = this.configProvider.getPrefixCls;
const prefixCls = getPrefixCls('btn', customizePrefixCls);
const autoInsertSpace = this.configProvider.autoInsertSpaceInButton !== false;

View File

@ -10,7 +10,7 @@ function getWatch(keys = []) {
const watch = {};
keys.forEach(k => {
watch[k] = function(value) {
this._proxyVm._data[k] = value;
this.configProvider[k] = value;
};
});
return watch;
@ -28,21 +28,19 @@ const ConfigProvider = {
pageHeader: PropTypes.object,
transformCellText: PropTypes.func,
},
setup(props, context) {
provide(
'configProvider',
reactive({
...props,
getPrefixCls: context.getPrefixCls,
renderEmpty: context.renderEmptyComponent,
}),
);
setup(props) {
const configProvider = reactive({
...props,
getPrefixCls: undefined,
renderEmpty: undefined,
});
provide('configProvider', configProvider);
return { configProvider };
},
created() {
this.configProvider.getPrefixCls = this.getPrefixCls;
this.configProvider.renderEmpty = this.renderEmpty;
},
// provide() {
// return {
// configProvider: this._proxyVm,
// };
// },
watch: {
...getWatch([
'prefixCls',

View File

@ -1,14 +1,18 @@
<template>
<a-config-provider prefixCls="ss">
jdjj
<div>ddd</div>
<a-config-provider>
<a-button-group class="dddd" style="color: red" @click="onClick">
<a-button>Cancel</a-button>
<a-button type="primary">
OK
</a-button>
</a-button-group>
<a-button
:class="['test']"
class="aaa"
style="display: inline"
block
@click="onClick"
:type="type"
@click="onClick"
>
Primary
</a-button>