您的位置:首页 > 教育 > 培训 > 南京制作手机网站_疫情再次传来坏消息_百度24小时人工客服_今日热点新闻事件摘抄

南京制作手机网站_疫情再次传来坏消息_百度24小时人工客服_今日热点新闻事件摘抄

2025/5/8 13:31:11 来源:https://blog.csdn.net/qq285744011/article/details/144426470  浏览:    关键词:南京制作手机网站_疫情再次传来坏消息_百度24小时人工客服_今日热点新闻事件摘抄
南京制作手机网站_疫情再次传来坏消息_百度24小时人工客服_今日热点新闻事件摘抄

须知

1Next.js 官网(英文)https://nextjs.org/
2Next.js 文档(中文)https://nextjscn.org/docs/
3Ant Design组件总览https://ant-design.antgroup.com/components/overview-cn
4tailwindcss类名大全 · 官网

https://www.tailwindcss.cn/docs/justify-content

5tailwindcss常用类名https://blog.csdn.net/delete_you/article/details/129965712
1参考项目 - Nextjs构建的电子商务应用程序 (Ecommerce-2023)
2参考项目 - 12个快速学会 NextJS 的 Github 仓库

react v19和antd诸多冲突,建议回退next.js v14 (配套react v18)

npx create-next-app@14.2.20

实现目标

0. 添加二级目录 - 项目打包后运行在https://xx.com/sub-folder/

1. 应用内页面跳转

2. 简单路由

3. 集成UI组件AntD

4. 在Next.js+AppRouter环境下使用AntD的子组件 (如Input下的TextArea) 

5. 穿透antd组件,修改css,“:global”的使用方法

6. 页面变量,点击事件,请求处理

7. 变量导致的报错"It only works in a Client Component but none of its parents are marked with “use client“"

8. AntD的按钮button绑定onClick后无限死循环 - 报错 - unhandledRejection: Error: Too many re-renders. React limits the number of renders to prevent an infinite loop.

9. AntD顶部通知 滚动通知 警告实现 alert message notice

10. Next.js报错 SSR导致的问题 “Hydration failed because the server rendered HTML didn't match the client. As a result this tree will be regenerated on the client. This can happen if a SSR-ed Client Component used”

11. Next.js报错 react19的error “intercept-console-error.js:56 Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release. error@intercept-console-error.js:56”

12. axios请求 / ajax请求

13. utils/fns实现

14. antd系列“card”卡片组件右上角副标题怎么自定义不同按钮 extra对象数组

15. React的显示隐藏控制 (v-if v-show)

16. nextjs build关闭eslint

17. React的复制功能 - 复制到剪切板 - copy

版本

  "dependencies": {

    "@ant-design/icons": "^5.5.2",

    "@ant-design/nextjs-registry": "^1.0.2",

    "antd": "^5.22.4",

    "axios": "^1.7.9",

    "next": "14.2.20",

    "react": "^18",

    "react-dom": "^18"

  },

  "devDependencies": {

    "@types/node": "^20",

    "@types/react": "^18",

    "@types/react-dom": "^18",

    "eslint": "^8",

    "eslint-config-next": "14.2.20",

    "postcss": "^8",

    "tailwindcss": "^3.4.1",

    "typescript": "^5"

  }

具体操作

0. 添加二级目录 - 项目打包后运行在https://xx.com/sub-folder/

参考 https://next.nodejs.cn/docs/app/api-reference/config/next-config-js/basePath

修改/next.config.ts,在nextConfig中写入 basePath: '/sub-folder'

1. 应用内页面跳转

import Link from 'next/link'
<Link href="/my">我的</Link>

应用外链接,可以用<a href="...">xx</a>
https://nextjscn.org/docs/app/building-your-application/routing/linking-and-navigating#link-组件

2. 简单路由

Next.js 基本路由跳转:

路由结构
https://nextjscn.org/docs/app/building-your-application/routing/defining-routes
例如:
应用首页 = /app/page.jsx 【后缀可以是jsx或者tsx】
个人首页 = /app/my/page.jsx 
个人订单 = /app/my/order/page.jsx 
那么,跳转方式就是
<Link href="/my">我的</Link>
<Link href="/my/order">我的订单</Link>

3. 集成UI组件AntD

参考 https://ant-design.antgroup.com/docs/react/use-with-next-cn

1. 安装antd组件
npm install antd --save2. 使用antd组件 - (修改/app/*/page.tsx 或jsx)
import { Button } from 'antd';
嵌套<Button type="primary">Button</Button>3. 特别注意!
如果使用了App Router,需要安装“nextjs-registry”:
npm install @ant-design/nextjs-registry --save
然后修改app/layout.tsx:
import { AntdRegistry } from '@ant-design/nextjs-registry';
将{children}使用此标签嵌套,例如:
<AntdRegistry>{children}</AntdRegistry>

AntD组件大全: 组件总览 - Ant Design

4. 在Next.js+AppRouter环境下使用AntD的子组件 (

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com