目前发送请求,请求回html:<div class="articleRecommendation_con">
<a href="https://weekly.caixin.com/2023-05-26/102059365.html"><img src="https://img.caixin.com/2023-05-27/168515251870385_145_97.jpg" alt=""></a>
<a href="https://weekly.caixin.com/2023-05-26/102059365.html">
<div class="articleRecommendation_con_right">
<p>财新周刊</p>
<p>最新封面报道|烟草反腐风暴</p>
<p><span>文|财新周刊 黄晏浩 于宁</span> <span>05月26日 21:58</span></p>
</div>
</a>
</div>
<div class="articleRecommendation_con">
<a href="https://www.caixin.com/2023-05-27/102059517.html"><img src="https://img.caixin.com/2023-05-27/168515857546679_145_97.jpg" alt=""></a>
<a href="https://www.caixin.com/2023-05-27/102059517.html">
<div class="articleRecommendation_con_right">
<p>能源</p>
<p>中创新航5月底集中解约应届毕业生 </p>
<p><span>文|财新 卢羽桐</span> <span>05月27日 11:33</span></p>
</div>
</a>
</div>
<div class="articleRecommendation_con">
<a href="https://china.caixin.com/2023-05-27/102059584.html"><img src="https://img.caixin.com/2023-05-27/168517636250497_145_97.jpg" alt=""></a>
<a href="https://china.caixin.com/2023-05-27/102059584.html">
<div class="articleRecommendation_con_right">
<p>政经</p>
<p>高额债务引发家庭矛盾 湖南长沙男子杀害一家四口后自杀</p>
<p><span>文|财新 何书舟(实习),黄雨馨</span> <span>05月27日 16:25</span></p>
</div>
</a>
</div>
<div class="articleRecommendation_con">
<a href="https://weekly.caixin.com/2023-05-27/102059400.html"><img src="https://img.caixin.com/2023-05-27/168515669738571_145_97.jpg" alt=""></a>
<a href="https://weekly.caixin.com/2023-05-27/102059400.html">
<div class="articleRecommendation_con_right">
<p>财新周刊</p>
<p>最新财新周刊|阿里分家</p>
<p><span>文|财新周刊 包云红(实习),张而弛 屈运栩</span> <span>05月27日 08:18</span></p>
</div>
</a>
</div>
<div class="articleRecommendation_con">
<a href="https://finance.caixin.com/2023-05-26/102059060.html"><img src="https://img.caixin.com/2023-05-26/168505643971469_145_97.jpg" alt=""></a>
<a href="https://finance.caixin.com/2023-05-26/102059060.html">
<div class="articleRecommendation_con_right">
<p>金融</p>
<p>兑付危机爆发三年后 四川信托牵头重组方初步明确</p>
<p><span>文|财新 刘冉</span> <span>05月26日 07:10</span></p>
</div>
</a>
</div>
<div class="articleRecommendation_con">
<a href="https://science.caixin.com/2023-05-26/102059214.html"><img src="https://img.caixin.com/2023-05-26/168508903204292_145_97.jpg" alt=""></a>
<a href="https://science.caixin.com/2023-05-26/102059214.html">
<div class="articleRecommendation_con_right">
<p>环科</p>
<p>马斯克旗下脑机接口公司获批进行人体试验</p>
<p><span>文|财新 徐路易</span> <span>05月26日 16:12</span></p>
</div>
</a>
</div>
调用接口,但是如果将返回数据的css写在文件中
是不会生效的,这时候应该如何?
我们先将写在文件中的css,const一个css参数,将css放进去
const css = `.taTitle {
display: block;
border-top: 2px solid rgba(250, 250, 250, 0.36);
height: 35px;
line-height: 35px;
font-family: PingFangSC-Regular, '微软雅黑';
font-size: 16px;
text-align: center;
margin-bottom: 14px;
}
.articleRecommendation_con{
clear: both;
margin: 6px 0px;
overflow: hidden;
}
.articleRecommendation_con a:nth-child(1) {
float: left;
width: 28%;
height: 66px;
padding: 5px 0px;
}
a:link {
text-decoration: none;
color: #ffffff;
}
.articleRecommendation_con a:nth-child(1) img {
width: 92%;
}
.articleRecommendation_con img {
overflow-clip-margin: content-box;
overflow: clip;
}
.articleRecommendation_con a:nth-child(2) {
display: block;
width: 72%;
float: left;
}
.articleRecommendation_con_right p:nth-child(1) {
display: none;
}
.articleRecommendation_con p {
display: block;
margin-block-start: 1em;
margin-block-end: 1em;
margin-inline-start: 0px;
margin-inline-end: 0px;
}
.articleRecommendation_con_right p:nth-child(2) {
margin: 0px;
line-height: 22px;
word-wrap: break-word;
text-align: left;
font-size: 14px;
}
.articleRecommendation_con_right p:nth-child(3) {
margin: 0px;
line-height: 20px;
word-wrap: break-word;
text-align: left;
}
.articleRecommendation_con_right p:nth-child(3) span:nth-child(1) {
display: none;
}
.articleRecommendation_con_right p:nth-child(3) span:nth-child(2) {
color: #ececec;
line-height: 20px;
font-family: PingFangSC-Regular, '微软雅黑';
font-size: 12px;
text-align: left;
}`
const sheet = new CSSStyleSheet();
sheet.replaceSync(css);
document.adoptedStyleSheets = [sheet];
然后就css生效了