我已经开发了Next.js服务器端渲染应用程序。我需要使用类似this的客户端渲染react应用来创建时间轴。
我将其用于应用程序的步骤:
我只是将src文件夹内容复制到我自己的应用程序的“ pages”文件夹中。
在我的应用程序的routes.js文件中,我将导航导航至App.js。
为了将CSS与Next.js一起使用(根据this链接):
我从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;
但是,现在当我转到页面时,什么都没有显示,也没有错误。
有人可以告诉我如何解决这个问题吗?