Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

can't use getComputedStyle when the component is mounted #175

Closed
liuyang0826 opened this issue May 18, 2020 · 0 comments · Fixed by #176
Closed

can't use getComputedStyle when the component is mounted #175

liuyang0826 opened this issue May 18, 2020 · 0 comments · Fixed by #176

Comments

@liuyang0826
Copy link

Do NOT ignore this template or your issue will have a very high chance to be closed without comment.

Describe the bug

When the component is mounted, getComputedStyle will get default style instead of the style in CSS

System Info

  • required vite version: 0.15.0
  • required Operating System: window10 x64. chrome 80
  • required Node version: 14.2.0
  • Optional:
    • npm/yarn version
    • Installed vue version (from yarn.lock or package-lock.json)
    • Installed @vue/compiler-sfc version

Logs (Optional if provided reproduction)

  1. Run vite or vite build with the --debug flag.
  2. Provide the error log here.

css:

.content {
  line-height: 24px;
}

js:

const contentRef = ref(null);
onMounted(() => {
  let { lineHeight, height } = getComputedStyle(contentRef.value);
  console.log(height, lineHeight);  // 63px normal
  showBtn.value = parseFloat(height) / parseFloat(lineHeight) > 2;
});
underfin added a commit to rolldown/vite that referenced this issue May 18, 2020
@github-actions github-actions bot locked and limited conversation to collaborators Jul 16, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant