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

beta22, the useCssModule did'nt adapt the change of getCurrentInstance. #620

Closed
Trendymen opened this issue Dec 31, 2020 · 2 comments
Closed

Comments

@Trendymen
Copy link
Contributor

Trendymen commented Dec 31, 2020

vue version: 2.6.12
@vuejs/composition-api version: 1.0.0-beta.22

beta22, the useCssModule did'nt adapt the change of getCurrentInstance.

export const useCSSModule = (name = '$style'): Record<string, string> => {
const instance = getCurrentInstance()
if (!instance) {
__DEV__ && warn(`useCSSModule must be called inside setup()`)
return EMPTY_OBJ
}
const mod = (instance as any)[name]
if (!mod) {
__DEV__ &&
warn(`Current instance does not have CSS module named "${name}".`)
return EMPTY_OBJ
}
return mod as Record<string, string>
}

export const useCSSModule = (name = '$style'): Record<string, string> => {
  const instance = getCurrentInstance()
  if (!instance) {
    __DEV__ && warn(`useCSSModule must be called inside setup()`)
    return EMPTY_OBJ
  }

  const mod = (instance as any)[name]   //Here
  if (!mod) {
    __DEV__ &&
      warn(`Current instance does not have CSS module named "${name}".`)
    return EMPTY_OBJ
  }

  return mod as Record<string, string>
}

image

@antfu
Copy link
Member

antfu commented Dec 31, 2020

Do you mind create a PR for it? Thanks

@Trendymen
Copy link
Contributor Author

Do you mind create a PR for it? Thanks

I will try , but I'm not familiar with the test part and the process of PR.

Trendymen added a commit to Trendymen/composition-api that referenced this issue Jan 5, 2021
@antfu antfu closed this as completed in 2ddead0 Jan 5, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants