xgqfrms™, xgqfrms® : xgqfrms's offical website of cnblogs! xgqfrms™, xgqfrms® : xgqfrms's offical website of GitHub!

taro external-class

taro external-class

https://nervjs.github.io/taro/docs/component-style.html

externalClasses

  1. child component

/* CustomComp.js */
export default class CustomComp extends Component {
  static externalClasses = ['my-class']

  render () {
    return <View className="my-class">这段文本的颜色由组件外的 class 决定</View>
  }
}

  1. parent component
/* MyPage.js */
export default class MyPage extends Component {
  render () {
    return <CustomComp my-class="red-text" />
  }
}

/* MyPage.scss */
.red-text {
  color: red;
}


全局样式类


posted @ 2020-03-31 14:31  xgqfrms  阅读(283)  评论(1编辑  收藏  举报