taro external-class
taro external-class
https://nervjs.github.io/taro/docs/component-style.html
externalClasses
- child component
/* CustomComp.js */
export default class CustomComp extends Component {
static externalClasses = ['my-class']
render () {
return <View className="my-class">这段文本的颜色由组件外的 class 决定</View>
}
}
- parent component
/* MyPage.js */
export default class MyPage extends Component {
render () {
return <CustomComp my-class="red-text" />
}
}
/* MyPage.scss */
.red-text {
color: red;
}
全局样式类
本文首发于博客园,作者:xgqfrms,原文链接:https://www.cnblogs.com/xgqfrms/p/12605043.html
未经授权禁止转载,违者必究!