简体   繁体   English

styled-jsx 中的:global 在 React.js 中如何工作?

[英]How does :global in styled-jsx work in React.js?

I do not understand the logic of:global() when working with classes from various different components using React.js.在使用 React.js 处理来自各种不同组件的类时,我不理解:global() 的逻辑。

  • what goes before the:global() syntax? :global() 语法之前是什么? and what within the brackets?括号内是什么?

    .select:global(.select__value) { some css } .select:global(.select__value) { 一些 css }

To change css code of some global class name component generally you should inspect your element to see what is the class name of that element and in brackets you should put that class name. To change css code of some global class name component generally you should inspect your element to see what is the class name of that element and in brackets you should put that class name.

For example if you do directly :global(.select__value) it will effect this component's css as global.例如,如果您直接执行:global(.select__value) ,它将将此组件的 css 影响为全局。 But if you do .classNameFather:global(.select__value) it will effect just this component in classNameFather instead of global change.但是如果你这样做.classNameFather:global(.select__value)它只会影响 classNameFather 中的这个组件,而不是全局更改。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM