当前位置: 首页 > news >正文

本地门户网站网站建设重要性

本地门户网站,网站建设重要性,宜州设计公司,linux wordpress是什么环境说明:next.js 官方文档要求node版本在16.8以上。笔者使用的 node版本是16.20.1,不要使用16.13.0,笔者在使用 node16.13.0环境时创建的 react 项目点击事件无效 next.js官网截图 next.js 官网:https://nextjs.org/ react 官网…

环境说明:next.js 官方文档要求node版本在16.8以上。笔者使用的 node版本是16.20.1,不要使用16.13.0,笔者在使用 node16.13.0环境时创建的 react 项目点击事件无效

next.js官网截图

 

next.js 官网:https://nextjs.org/

react 官网:https://react.dev/

Ant Design 官网:https://ant.design/index-cn

目录

1、创建项目

2、安装 ant design

3、运行测试


1、创建项目

在电脑存放项目的文件夹下打开cmd窗口

执行命令创建项目 npx create-next-app antd-demo

npx create-next-app antd-demo

第一次创建会先安装 create-next-app

接下来会让你选择创建项目需要的内容,这里可以根据自己的喜好决定,或者直接使用默认

笔者选择的是使用 ts 和 app router

 创建完成

2、安装 ant design

进入项目目录 ,使用 vscode编辑器打开项目

cd antd-demo
code ./

安装 ant design react

npm install antd --save
npm install @ant-design/cssinjs --save

安装完成后,在项目src目录下新建 lib 目录,在新建的 lib 目录下新建  AntdRegistry.tsx

 AntdRegistry.tsx内容

'use client';import React from 'react';
import { StyleProvider, createCache, extractStyle } from '@ant-design/cssinjs';
import { useServerInsertedHTML } from 'next/navigation';const StyledComponentsRegistry = ({ children }: { children: React.ReactNode }) => {const cache = createCache();useServerInsertedHTML(() => (<style id="antd" dangerouslySetInnerHTML={{ __html: extractStyle(cache, true) }} />));return <StyleProvider cache={cache}>{children}</StyleProvider>;
};export default StyledComponentsRegistry;

vscode 截图

修改src/app/layout.tsx 内容为下面内容

import React from 'react';
import { Inter } from 'next/font/google';
import StyledComponentsRegistry from '../lib/AntdRegistry';
import '@/app/globals.css';const inter = Inter({ subsets: ['latin'] });export const metadata = {title: 'Create Next App',description: 'Generated by create next app',
};const RootLayout = ({ children }: { children: React.ReactNode }) => (<html lang="en"><body className={inter.className}><StyledComponentsRegistry>{children}</StyledComponentsRegistry></body></html>
);export default RootLayout;

vscode 截图

添加主题配置 

在项目根目录下新建 theme 文件夹,新建 themeConfig.ts

 themeConfig.ts 内容

// theme/themeConfig.ts
import type { ThemeConfig } from 'antd';const theme: ThemeConfig = {token: {fontSize: 16,colorPrimary: '#52c41a',},
};export default theme;

vscode 截图

修改app下page.tsx 内容为下面内容

'use client';
import React from 'react';
import { Button, message, ConfigProvider } from 'antd';
import theme from './../../theme/themeConfig';export default function Home() {const [messageApi, contextHolder] = message.useMessage();const add = ()=>{messageApi.open({type: 'success',content: '宜将剩勇追穷寇,不可沽名学霸王',});}return (<ConfigProvider theme={theme}><div className="App">{contextHolder}<Button onClick={add} type="primary">Button</Button></div></ConfigProvider>)
}

 vscode 截图

3、运行测试

在项目根目录下打开cmd,也可使用vscode自带的终端运行命令,npm run dev

npm run dev

 

浏览器访问:http://localhost:3000 

 

这个背景的条纹是next.js自带的样式,如果想去掉它,可以将 app/globals.css 的 body 标签的背景background 样式去掉

body {margin: 0;color: rgb(var(--foreground-rgb));/* background: linear-gradient(to bottom,transparent,rgb(var(--background-end-rgb)))rgb(var(--background-start-rgb)); */
}

运行效果

 

至此完

http://www.yayakq.cn/news/396305/

相关文章:

  • 中科院网站做的好的院所网站关键词排名服务
  • 代做施组 方案的网站企业网站建设方案怎么写
  • 全栈网站开发流行框架wordpress后台破解
  • 网站建设面板免费领云服务器
  • 手机建网站花钱吗如何使用wordpress主题
  • 协会网站建设方案书石家庄市做网站
  • 策划的网站如何做好网络营销工作
  • 山东省郓城县建设局官方网站视频网站开发技术书
  • 企业网站部署计划做网站还要维护吗
  • 增加网站关键词免费注册tk域名
  • wordpress无插件实现网站地图wordpress自建菜单
  • php软件网站建设html网页大赛优秀作品
  • 樟树网站建设wordpress多站点demo
  • 学做各种糕点的网站比特币网站怎么做
  • 网络营销推广排名优化关键词公司
  • 个人怎么注册网站侯马网站建设
  • 网站被入侵后需做的检测 1上海模板开发建站
  • 手机网站设计企业重庆特种作业证件查询
  • 自己的公网ip可以做网站河北网站建设备案价格
  • 网站域名icp备案查询在线建站模板
  • 建站网站企业数字展厅设成都企业展厅设计公司
  • 生活信息网站建设中小企业网站营销
  • 广西做网站找谁the author wordpress
  • 公司网站建设多少费用兴田德润在哪里图案设计素材
  • 提高网站目标流量o2o苗木网站建设
  • 网站开发中 整体框架的架构电商网站设计是什么
  • 一个页面的网站上海网站制作商
  • 网站建设成功案例方案财经网站源码 织梦
  • 建设公司网站大概需要多少钱?代做效果图的网站好
  • 济南历山北路网站建设网页设计需要学什么学历