next
sonder 中杯

基于react技术栈的服务端渲染解决方案

1
2
3
4
5
6
7
8
// 安装脚手架快速创建项目
npm install -g create-next-app

// 创建项目
npx create-next-app next-create

// 启动项目
npm run dev

使用antd

  • 安装依赖
1
2
3
yarn add @zeit/next-css  antd  babel-plugin-import 
// or
npm i --save @zeit/next-css antd babel-plugin-import
  • 创建next-config.js
1
2
3
4
5
const withCss = require("@zeit/next-css");
if (typeof require !== "undefined") {
require.extensions[".css"] = file => {};
}
module.exports=withCss({})

创建.babelrc

1
2
3
4
5
6
7
8
9
10
11
12
{
"presets":["next/babel"],
"plugins":[
[
"import",
{
"libraryName":"antd",
"style":"css"
    }
]
]
}

创建 ._app.js

1
2
3
import App from "next/app";
import "antd/dist/antd.css";
export default App;
  • 本文标题:next
  • 本文作者:sonder
  • 创建时间:2020-07-06 14:44:06
  • 本文链接:https://sonderss.github.io/2020/07/06/next/
 评论