如题:
在React项目中使用style标签, 伪代码如下:
xx.scss 文件
.xx:{
position: fixed;
bottom: 0;
right: 0;
z-index: 1001;
width: 270px;
-webkit-box-sizing: border-box;
box-sizing: border-box;
}
组件文件:
import Style from xx
<div className=xx>
<style dangerouslySetInnerHTML={{ __html: Style }} /
</div>
在console
一直报 Warning: Prop dangerouslySetInnerHTML did not match.
, 将 <style dangerouslySetInnerHTML={{ __html: Style }}
改写为
style dangerouslySetInnerHTML={{ __html: `
.xx:{
position: fixed;
bottom: 0;
right: 0;
z-index: 1001;
width: 270px;
-webkit-box-sizing: border-box;
box-sizing: border-box;
}
` }}
则错误消失;求指导
既然这样为什么不直接
import xx;