-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
taro 3.0 + Vue 中scoped在h5下生效,在微信小程序中无效 #6662
Comments
@XboxYan 使用 cssModules 吧,小程序不支持给节点动态添加属性 |
@Chen-jj cssModules也有问题,只能设置 // config/index.js
const config = {
// ...
h5: {
//...
cssModules: {
enable: true, // 使用 css modules 功能,设为 true
config: {
namingPattern: "global", // 转换模式
generateScopedName: "[name]__[local]___[hash:base64:5]"
}
}
}
}
} 同时,在module样式表中,引入其他样式在 H5 中无效,小程序中却生效 <style module>
@import 'index.scss'; /* 在 H5 中无效,小程序中生效 */
.red{
color: red;
}
</style> |
遇到了类似的问题。 taro版本3.0.2 目前的生效方式在 cssLoaderOption: {
modules: {
mode: 'global',
localIdentName: '[name]__[local]___[hash:base64:5]'
}
}, 一点小建议mpvue里实现了 |
瞬间不香了 |
同问,是否有解决方法 |
微信小程序不支持属性选择器,添加了也没用。 为什么不参考mpvue、uni-app动态添加class实现支持? |
确实,可以考虑动态添加 class 实现支持 |
手动添加class方案:
|
参考:https://taro-docs.jd.com/taro/docs/css-modules/
2.将
|
uni-app是可以的,不知道能不能参考 实现? |
@JiaLe1 |
taro + vue3
|
有解决方案了吗 |
蹲一个~ |
备注:是因为小程序环境启用了 postcss 插件 |
蹲一波更新 |
大佬,我也觉得Css Module 很香 |
从性能上考虑来说,在小程序里面,能用css解决的问题,最好不要用js的方式,希望大佬们能攻克css的难题,发展更完美的css方式 |
Gently pinging on this issue |
微信小程序现已支持data-*属性选择器, 可否考虑实现<style scoped>了 |
同,之前狠狠地踩了一波坑( |
都2023年了,还不行吗,笑死 |
看来taro+vue只有一个cssModule选项了 |
只有我坚守BEM方案么,毫无障碍 |
taro css scoped 这个功能要是完善了,然后再加上 4.x vite 功能稳定,就完美了,至少可以完美个2年+,加油加油! |
https://github.com/stellaround/convert-vue-scoped |
2024年了,还没有实现css scope 吗?? 太滑稽了,每次更新版本都在实现什么啊??? |
非专业前端,想尝试下Taro结果没走几步就掉这个坑了..希望尽快支持Vue的scoped |
从官网文档走过来 从最上一条一字不落下看到下面 终于有比较满意的了 点赞加关注 回头让小伙伴们试试看。 |
终究是错付了 |
没有scoped开发体验实在是太差了 |
any? |
对vite 的支持都慢的要死,scoped,再等一年吧 |
any? |
问题描述
taro 3.0 + Vue 中scoped在h5下生效,在微信小程序中无效
复现步骤
Vue 引入了组件作用域的概念,通过在style标签上添加scoped属性,让这一部分 CSS 只在该组件内有效
内部原理是,这个可选 scoped 属性会自动添加一个唯一的 属性 (比如 data-v-21e5b78) 为组件内 CSS 指定作用域,编译的时候 .red 会被编译成类似 .red[data-v-21e5b78]
H5模式下dom生成了[data-v-xxx]属性
微信小程序模式下没有生成[data-v-xxx]属性
期望行为
在微信小程序中正常
系统信息
Taro v3.0.0-rc.4
The text was updated successfully, but these errors were encountered: