-
Notifications
You must be signed in to change notification settings - Fork 344
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
Cannot work with CSS Modules #21
Labels
Comments
Also, when using without custom inject names, context does not have the property <script>
export default {
setup(props, context) {
// Get undefined instead of { wrapper: <random-string> }
return context.$style;
}
}
</script>
<style module>
.wrapper {
background: #000;
}
</style> |
As a workaround, depending on your usage, it is possible to extract <script>
import { onBeforeMount } from '@vue/composition-api';
export default {
setup() {
const css = { $a, $b, $style };
onBeforeMount(function(){
({ $a: css.$a, $b: css.$b, $style: css.$style } = this);
});
// css.$a, css.$b, css.$style are now available for use in computed properties, etc.
return {
// no need to return $a/$b/$styles, added to instance by vue-loader
};
}
}
</script>
<style module>
.wrapper {
background: #000;
}
</style>
<style module="$a">
.wrapper {
background: #ccc;
}
</style>
<style module="$b">
.wrapper {
background: #fff;
}
</style>
|
My workaround import { getCurrentInstance } from '@vue/composition-api';
export default {
setup () {
const { $style } = getCurrentInstance()!
}
} |
See useCssModule |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
setup (props, context)
cannot work with CSS Modules, becausecontext
does not has property$a
or$b
.The text was updated successfully, but these errors were encountered: