Next.js 学习笔记(二)- 使用 Antd 组件库

153 阅读1分钟

使用

1.安装 antd

yarn add antd

2.在 pages/_app.js 文件中配置 antd 样式

引入组件的时候自带样式,但是需要先构建一下

pnpm build

pnpm start

3.在页面中引入组件

import React from 'react' 

import Head from 'next/head' 

import {Button} from 'antd' 
const Home = () => ( <> <Head> <title>Home</title> </Head> <div>
<Button>我是按钮</Button>
</div> </> ) 

export default Home

4.成功