fix: affix $refs.placeholderNode cannot get

pull/2365/head^2
tanjinzhou 2020-06-08 17:43:10 +08:00
parent 8b4c55c75f
commit 424c880fbf
1 changed files with 4 additions and 9 deletions

View File

@ -131,12 +131,7 @@ const Affix = {
measure() { measure() {
const { status, lastAffix } = this; const { status, lastAffix } = this;
const { target } = this; const { target } = this;
if ( if (status !== AffixStatus.Prepare || !this.$refs.fixedNode || !this.$el || !target) {
status !== AffixStatus.Prepare ||
!this.$refs.fixedNode ||
!this.$refs.placeholderNode ||
!target
) {
return; return;
} }
@ -152,7 +147,7 @@ const Affix = {
status: AffixStatus.None, status: AffixStatus.None,
}; };
const targetRect = getTargetRect(targetNode); const targetRect = getTargetRect(targetNode);
const placeholderReact = getTargetRect(this.$refs.placeholderNode); const placeholderReact = getTargetRect(this.$el);
const fixedTop = getFixedTop(placeholderReact, targetRect, offsetTop); const fixedTop = getFixedTop(placeholderReact, targetRect, offsetTop);
const fixedBottom = getFixedBottom(placeholderReact, targetRect, offsetBottom); const fixedBottom = getFixedBottom(placeholderReact, targetRect, offsetBottom);
if (fixedTop !== undefined) { if (fixedTop !== undefined) {
@ -214,9 +209,9 @@ const Affix = {
const offsetBottom = this.getOffsetBottom(); const offsetBottom = this.getOffsetBottom();
const targetNode = target(); const targetNode = target();
if (targetNode && this.$refs.placeholderNode) { if (targetNode && this.$el) {
const targetRect = getTargetRect(targetNode); const targetRect = getTargetRect(targetNode);
const placeholderReact = getTargetRect(this.$refs.placeholderNode); const placeholderReact = getTargetRect(this.$el);
const fixedTop = getFixedTop(placeholderReact, targetRect, offsetTop); const fixedTop = getFixedTop(placeholderReact, targetRect, offsetTop);
const fixedBottom = getFixedBottom(placeholderReact, targetRect, offsetBottom); const fixedBottom = getFixedBottom(placeholderReact, targetRect, offsetBottom);