首页 > 解决方案 > 从 Create-React-App 升级到 Next.js - 什么都没有显示

问题描述

我开发了一个 Next.js 服务器端渲染应用程序。我需要使用像这样的客户端渲染反应应用程序来创建时间线。

我在我的应用程序中使用它的步骤

我刚刚将 src 文件夹内容复制到我自己的应用程序的“页面”文件夹中。

在我的应用程序的 routes.js 文件中,我提供了 App.js 的导航。

为了将 CSS 与 Next.js 一起使用(根据链接):

我从 Next 导入 Head 并添加了指向 CSS 文件的链接。

所以,文件(App.js)现在看起来像这样:

 import React, { Component } from 'react';
 import Timeline from './components/Timeline';
 import Head from 'next/head';

 class App extends Component {

   state = {
    timelineData: [
    {
      text: 'Wrote my first blog post ever on Medium',
      date: 'March 03 2017',
      category: {
        tag: 'medium',
        color: '#018f69'
    }
  },
  {
    text: 'This is the second timeline item',
    date: 'September 22 2017',
    category: {
        tag: 'tag-two',
        color: '#018f69'
     }
   }
 ]
}

render() {
  return (
    <div className="App">
      <Head>
       <link href="/App.css" rel="stylesheet" />
      </Head>
      <Timeline data={this.state.timelineData} />
    </div>
 );
 }
}

export default App;

但是,现在当我转到该页面时,什么都没有显示,也没有错误。

有人可以告诉我如何解决这个问题吗?

标签: javascriptnode.jsreactjsnext.jsserver-side-rendering

解决方案


推荐阅读