fix: anchor provide not work

pull/2365/head^2
tanjinzhou 2020-06-08 17:42:35 +08:00
parent c0adff7695
commit 8b4c55c75f
1 changed files with 21 additions and 24 deletions

View File

@ -1,4 +1,4 @@
import { inject } from 'vue';
import { inject, provide } from 'vue';
import PropTypes from '../_util/vue-types';
import classNames from 'classnames';
import addEventListener from '../vc-util/Dom/addEventListener';
@ -99,11 +99,6 @@ export default {
showInkInFixed: false,
getContainer: getDefaultContainer,
}),
setup() {
return {
configProvider: inject('configProvider', ConfigConsumerProps),
};
},
data() {
this.links = [];
this._sPrefixCls = '';
@ -111,9 +106,8 @@ export default {
activeLink: null,
};
},
provide() {
return {
antAnchor: {
created() {
provide('antAnchor', {
registerLink: link => {
if (!this.links.includes(link)) {
this.links.push(link);
@ -127,11 +121,14 @@ export default {
},
$data: this.$data,
scrollTo: this.handleScrollTo,
});
provide('antAnchorContext', this);
},
antAnchorContext: this,
setup() {
return {
configProvider: inject('configProvider', ConfigConsumerProps),
};
},
mounted() {
this.$nextTick(() => {
const { getContainer } = this;