我无法在 React 中将代码渲染为段落

发布: (2025年12月8日 GMT+8 00:24)
1 min read
原文: Dev.to

Source: Dev.to

问题

我正在尝试在 React 组件中将一段代码块渲染为段落,但它没有正确显示。

代码

const VideoExample = () => {
  const VideoCode = function Video({ video }) {
    return (
      <>
        
### {video.title}

        
{video.description}

      
    );
  };

  return (
    
      
        Create user interfaces 
 from components
      
      
        
          React lets you build user interfaces out of individual pieces called
          components.
        
        
          Create your own React components like{' '}
          Thumbnail,{' '}
          LikeButton, and{' '}
          Video.
        
        
Then combine them into entire screens, pages, and apps.

      

      
        
          
            
Video.js

          
          
            
              `{VideoCode}`
            
          
        
      
    
  );
};

export default VideoExample;

结果

渲染输出

Back to Blog

相关文章

阅读更多 »

Reatom:随你成长的状态管理

碎片化问题 现代前端开发有一个常见的模式: - 从简单的 useState hook 开始 - 需要共享状态?添加 Context - Context re‑...

滚开联系页面

请提供您希望翻译的具体摘录或摘要文本,我才能为您进行翻译。