惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
腾讯CDC
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
L
LINUX DO - 热门话题
D
Darknet – Hacking Tools, Hacker News & Cyber Security
Project Zero
Project Zero
V
Vulnerabilities – Threatpost
Cisco Talos Blog
Cisco Talos Blog
P
Palo Alto Networks Blog
C
Cisco Blogs
A
Arctic Wolf
月光博客
月光博客
The GitHub Blog
The GitHub Blog
T
The Blog of Author Tim Ferriss
量子位
小众软件
小众软件
Latest news
Latest news
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
Microsoft Security Blog
Microsoft Security Blog
T
The Exploit Database - CXSecurity.com
Security Latest
Security Latest
N
Netflix TechBlog - Medium
K
Kaspersky official blog
人人都是产品经理
人人都是产品经理
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
博客园_首页
Y
Y Combinator Blog
P
Proofpoint News Feed
H
Hackread – Cybersecurity News, Data Breaches, AI and More
M
MIT News - Artificial intelligence
T
Threat Research - Cisco Blogs
S
Schneier on Security
D
Docker
Scott Helme
Scott Helme
MyScale Blog
MyScale Blog
Spread Privacy
Spread Privacy
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
GbyAI
GbyAI
有赞技术团队
有赞技术团队
Google DeepMind News
Google DeepMind News
The Hacker News
The Hacker News
H
Help Net Security
Simon Willison's Weblog
Simon Willison's Weblog
J
Java Code Geeks
C
Cyber Attacks, Cyber Crime and Cyber Security
T
Tenable Blog
B
Blog
Know Your Adversary
Know Your Adversary
IT之家
IT之家

补陋阁 RSS 2.0

补陋阁 补陋阁 补陋阁 补陋阁 补陋阁 补陋阁 补陋阁 补陋阁 补陋阁
补陋阁
补陋阁 · 2025-11-23 · via 补陋阁 RSS 2.0

起因

最近再重构博客文本的代码块,用上了AI帮忙生成了React的代码样式,照搬到了Vue发现样式有问题。

排查

<pre className="m-0 p-0 bg-transparent font-mono text-sm leading-6 text-gray-300" style={{ tabSize: 2 }}>
  <code>
    {lines.map((line, i) => (
  <div key={i} className="whitespace-pre group/line">
    {/* Simple pseudo-syntax highlighting wrapper */}
    <LineContent line={line} />
  </div>
))}
  </code>
</pre>

上面的是react的代码,下面的是vue的代码

<pre class="m-0 p-0 bg-transparent font-mono text-sm leading-6 text-gray-300">
  <code>
    <div v-for="(line ,index) in lines" :key="index" v-html="highlightedCode(line, language)"/>
  </code>
</pre>

vue的效果就是和react差距在react的可以和行数对齐,vue的上下都会留白。我检查了react项目中的其余css样式,也都没有单独针对<pre>标签的,我发现在vue中将<pre>改为<div>就不会上下留白,我当时初步怀疑是样式问题,所以一直再找2者之间的区别,后面单独在react项目中的html文件里也写了同样的<pre>代码,发现也有留白,我就一直怀疑是不是react是不是有什么特殊处理。

在我遍寻AIGoogle的时候都没法解决的时候,尝试问了一下热心的群友,他当即给我发了下面三张图片,以解我的疑惑。

反思

这次踩坑就是自己的基础太差没有打牢根基,因为这种小问题也是浪费了4个小时再排查。

这篇博客也是加以反思吧。还有就是有问题多问,不要闷头干,说不定别人的一句话就能点醒你。😭

最后也是查了一下为什么react可以,vue不行。以下是Chatgpt的回答