uniapp 中使用 tsx ,引入css module,在安卓不生效,在H5上生效,
示例代码:
index.module.scss
.content {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
.logo {
height: 200rpx;
width: 200rpx;
margin-top: 200rpx;
margin-left: auto;
margin-right: auto;
margin-bottom: 50rpx;
}
.text-area {
display: flex;
justify-content: center;
}
.title {
font-size: 36rpx;
color: #8f8f94;
}
}
index.tsx
import { defineComponent, ref } from 'vue'
import styles from './index.module.scss'
export default defineComponent({
name: 'index',
setup() {
console.log(styles)
const title = ref('Hello')
return {title}
},
render(){
return (<view class={styles.content}>
<image style={styles.logo} src="/static/logo.png"></image>
<view class={styles['text-area']}>
<text class={styles.title}>{this.title}</text>
</view>
</view>)
}
})
在H5上有样式
![](http://img-cdn-tc.dcloud.net.cn/uploads/questions/20230201/247eb8a1b3384fb76f4e1ba164583b00.png)
在Android上没有样式