feat: update grid (#2377)
* feat: update grid * fix: row can't provide rowContext to col Co-authored-by: tangjinzhou <415800467@qq.com>pull/2415/head
parent
585bb7495b
commit
f2af8d248e
|
@ -1,9 +1,7 @@
|
||||||
import { Col } from '../grid';
|
import { Col } from '../grid';
|
||||||
import Base from '../base';
|
|
||||||
/* istanbul ignore next */
|
/* istanbul ignore next */
|
||||||
Col.install = function(Vue) {
|
Col.install = function(app) {
|
||||||
Vue.use(Base);
|
app.component(Col.name, Col);
|
||||||
Vue.component(Col.name, Col);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export default Col;
|
export default Col;
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
|
import { inject } from 'vue';
|
||||||
import PropTypes from '../_util/vue-types';
|
import PropTypes from '../_util/vue-types';
|
||||||
import { ConfigConsumerProps } from '../config-provider';
|
import { ConfigConsumerProps } from '../config-provider';
|
||||||
import { getListeners } from '../_util/props-util';
|
|
||||||
|
|
||||||
const stringOrNumber = PropTypes.oneOfType([PropTypes.string, PropTypes.number]);
|
const stringOrNumber = PropTypes.oneOfType([PropTypes.string, PropTypes.number]);
|
||||||
|
|
||||||
|
@ -32,11 +32,11 @@ export const ColProps = {
|
||||||
export default {
|
export default {
|
||||||
name: 'ACol',
|
name: 'ACol',
|
||||||
props: ColProps,
|
props: ColProps,
|
||||||
inject: {
|
setup() {
|
||||||
configProvider: { default: () => ConfigConsumerProps },
|
return {
|
||||||
rowContext: {
|
configProvider: inject('configProvider', ConfigConsumerProps),
|
||||||
default: () => null,
|
rowContext: inject('rowContext', null),
|
||||||
},
|
};
|
||||||
},
|
},
|
||||||
render() {
|
render() {
|
||||||
const {
|
const {
|
||||||
|
@ -82,7 +82,6 @@ export default {
|
||||||
...sizeClassObj,
|
...sizeClassObj,
|
||||||
};
|
};
|
||||||
const divProps = {
|
const divProps = {
|
||||||
on: getListeners(this),
|
|
||||||
class: classes,
|
class: classes,
|
||||||
style: {},
|
style: {},
|
||||||
};
|
};
|
||||||
|
@ -105,6 +104,6 @@ export default {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return <div {...divProps}>{$slots.default}</div>;
|
return <div {...divProps}>{$slots.default && $slots.default()}</div>;
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
import { inject, provide, reactive } from 'vue';
|
||||||
import PropTypes from '../_util/vue-types';
|
import PropTypes from '../_util/vue-types';
|
||||||
import BaseMixin from '../_util/BaseMixin';
|
import BaseMixin from '../_util/BaseMixin';
|
||||||
import { ConfigConsumerProps } from '../config-provider';
|
import { ConfigConsumerProps } from '../config-provider';
|
||||||
|
@ -20,20 +21,24 @@ export default {
|
||||||
...RowProps,
|
...RowProps,
|
||||||
gutter: PropTypes.oneOfType([PropTypes.object, PropTypes.number, PropTypes.array]).def(0),
|
gutter: PropTypes.oneOfType([PropTypes.object, PropTypes.number, PropTypes.array]).def(0),
|
||||||
},
|
},
|
||||||
provide() {
|
setup() {
|
||||||
|
const rowContext = reactive({
|
||||||
|
getGutter: undefined,
|
||||||
|
});
|
||||||
|
provide('rowContext', rowContext);
|
||||||
return {
|
return {
|
||||||
rowContext: this,
|
configProvider: inject('configProvider', ConfigConsumerProps),
|
||||||
|
rowContext,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
inject: {
|
|
||||||
configProvider: { default: () => ConfigConsumerProps },
|
|
||||||
},
|
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
screens: {},
|
screens: {},
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
created() {
|
||||||
|
this.rowContext.getGutter = this.getGutter;
|
||||||
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
this.$nextTick(() => {
|
this.$nextTick(() => {
|
||||||
this.token = ResponsiveObserve.subscribe(screens => {
|
this.token = ResponsiveObserve.subscribe(screens => {
|
||||||
|
@ -101,7 +106,7 @@ export default {
|
||||||
};
|
};
|
||||||
return (
|
return (
|
||||||
<div class={classes} style={rowStyle}>
|
<div class={classes} style={rowStyle}>
|
||||||
{$slots.default}
|
{$slots.default && $slots.default()}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|
|
@ -1,10 +1,8 @@
|
||||||
import { Row } from '../grid';
|
import { Row } from '../grid';
|
||||||
import Base from '../base';
|
|
||||||
|
|
||||||
/* istanbul ignore next */
|
/* istanbul ignore next */
|
||||||
Row.install = function(Vue) {
|
Row.install = function(app) {
|
||||||
Vue.use(Base);
|
app.component(Row.name, Row);
|
||||||
Vue.component(Row.name, Row);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export default Row;
|
export default Row;
|
||||||
|
|
|
@ -17,6 +17,8 @@ import PageHeader from 'ant-design-vue/page-header';
|
||||||
import Skeleton from 'ant-design-vue/skeleton';
|
import Skeleton from 'ant-design-vue/skeleton';
|
||||||
import Empty from 'ant-design-vue/empty';
|
import Empty from 'ant-design-vue/empty';
|
||||||
import Timeline from 'ant-design-vue/timeline';
|
import Timeline from 'ant-design-vue/timeline';
|
||||||
|
import Col from 'ant-design-vue/col';
|
||||||
|
import Row from 'ant-design-vue/row';
|
||||||
import Tooltip from 'ant-design-vue/tooltip';
|
import Tooltip from 'ant-design-vue/tooltip';
|
||||||
import 'ant-design-vue/style.js';
|
import 'ant-design-vue/style.js';
|
||||||
|
|
||||||
|
@ -37,5 +39,7 @@ createApp(App)
|
||||||
.use(Spin)
|
.use(Spin)
|
||||||
.use(Empty)
|
.use(Empty)
|
||||||
.use(Timeline)
|
.use(Timeline)
|
||||||
|
.use(Col)
|
||||||
|
.use(Row)
|
||||||
.use(Tooltip)
|
.use(Tooltip)
|
||||||
.mount('#app');
|
.mount('#app');
|
||||||
|
|
Loading…
Reference in New Issue