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

广西网站建设运营费用智能建站平台

广西网站建设运营费用,智能建站平台,获奖设计网站,wordpress第三方订阅地址创建项目 npx create-next-app 项目名 体验文件路由 nextjs提供了文件路由的功能, 根据文件系统的目录结构, 可以识别为对应的页面路由 创建页面 首先, 在src下创建pages目录, 然后创建一个about文件(对应about页面)和main/index.js文件(对应首页) pages/main/index con…

创建项目

npx create-next-app 项目名

体验文件路由 

nextjs提供了文件路由的功能, 根据文件系统的目录结构, 可以识别为对应的页面路由

创建页面

首先, 在src下创建pages目录, 然后创建一个about文件(对应about页面)和main/index.js文件(对应首页)

pages/main/index 

const Main=()=>{return (<div>main</div>)
}export default Main

pages/about.js

const About = () => {return (<div>about</div>)
}export default About

启动项目并查看页面

npm run dev

pages下的文件, 文件名作为路由, 显示为页面

pages下的文件夹, 文件夹的名称作为路由, 对应该文件夹的index文件的内容

多级路由

创建pages/content/mutli/a目录, 然后创建两个文件(index和test)

pages/content/multi/a/index.jsx
const Index = () => {return (<>index</>)
}
export default Index

pages/content/multi/a/test
 

const Test = () => {return (<>test</>)
}
export default Test

访问页面

 

动态路由

nextjs支持文件路由拥有动态的路径参数, 文件名称为 [参数名].js或jsx , 我们创建pages/dynamic/[id].jsx

pages/dynamic/[id].jsx
import {useRouter} from "next/router";export default function DynamicId() {const router = useRouter()console.log(router)return (<div>{/*获取路由参数*/}current id - {router.query["id"]}</div>)
}
访问页面

slug 长路由

nextjs支持匹配一个路由下的多级子路由

pages/dynamic/[...slug].js
import {useRouter} from "next/router";const Slug = () => {let slug = [];const router = useRouter();slug = router.query.slug;return (<div><ul>{slug ?slug.map((slug, i) => <li key={i}>{slug}</li>) :<></>}</ul></div>);
};export default Slug;
访问页面

这里应该是匹配到[id]了

 路由跳转

我们使用Link组件来跳转
pages/main/index.js
import Link from "next/link";const Main = () => {return (<div><Link href={'/dynamic/123'}>to dynamic id</Link></div>)
}export default Main
访问页面

整合chakra组件库

安装依赖

npm i @chakra-ui/react @chakra-ui/next-js @emotion/react @emotion/styled framer-motion

设置

// pages/_app.js
import { ChakraProvider } from '@chakra-ui/react'
// 个人踩坑
// 如果用了_app.js, 就需要在这里也引入globals.css或tailwind的css配置, 才能使tailwind生效
import '@/app/globals.css'function MyApp({ Component, pageProps }) {return (<ChakraProvider><Component {...pageProps} /></ChakraProvider>)
}export default MyApp

应用程序目录设置

// app/providers.tsx
'use client'import { CacheProvider } from '@chakra-ui/next-js'
import { ChakraProvider } from '@chakra-ui/react'export function Providers({ children }: { children: React.ReactNode }) {return (<CacheProvider><ChakraProvider>{children}</ChakraProvider></CacheProvider>)
}

// app/layout.tsx
import { Providers } from './providers'export default function RootLayout({children}) {return (<html lang="en"><body className={inter.className}><Providers>{children}</Providers></body></html>)
}

使用

pages/main/index.js
import Link from "next/link";
import {Alert,AlertIcon,
} from '@chakra-ui/react'const Main = () => {return (<div><Alert status='success'><AlertIcon />Data uploaded to the server. Fire on!</Alert><Link href={'/dynamic/123'}>to dynamic id</Link></div>)
}export default Main


文章转载自:
http://dinncogross.wbqt.cn
http://dinncobedrabble.wbqt.cn
http://dinncocoastland.wbqt.cn
http://dinncoimmune.wbqt.cn
http://dinncochirurgeon.wbqt.cn
http://dinncoswbs.wbqt.cn
http://dinncotaeniafuge.wbqt.cn
http://dinncotippytoe.wbqt.cn
http://dinncohowl.wbqt.cn
http://dinncologgets.wbqt.cn
http://dinncocalorimetry.wbqt.cn
http://dinncophotofit.wbqt.cn
http://dinncodespatch.wbqt.cn
http://dinncometaphrase.wbqt.cn
http://dinncocoition.wbqt.cn
http://dinncopsig.wbqt.cn
http://dinncominicar.wbqt.cn
http://dinncocranked.wbqt.cn
http://dinncocommando.wbqt.cn
http://dinncoforworn.wbqt.cn
http://dinncobeamingly.wbqt.cn
http://dinncobraceleted.wbqt.cn
http://dinncopiggin.wbqt.cn
http://dinncoglobulet.wbqt.cn
http://dinncoprotamin.wbqt.cn
http://dinncoflockbed.wbqt.cn
http://dinncouniface.wbqt.cn
http://dinncosemiofficially.wbqt.cn
http://dinncoragefully.wbqt.cn
http://dinncoiniquitous.wbqt.cn
http://dinncoparorexia.wbqt.cn
http://dinncochummy.wbqt.cn
http://dinncocatachrestically.wbqt.cn
http://dinncodiurnation.wbqt.cn
http://dinncoaforetime.wbqt.cn
http://dinncoexchengeable.wbqt.cn
http://dinncoscholastic.wbqt.cn
http://dinncograndiose.wbqt.cn
http://dinncoracketeer.wbqt.cn
http://dinncoblest.wbqt.cn
http://dinncopartyism.wbqt.cn
http://dinncotousle.wbqt.cn
http://dinncoemancipatory.wbqt.cn
http://dinncoalgatron.wbqt.cn
http://dinncobibiolatrist.wbqt.cn
http://dinncoanthropology.wbqt.cn
http://dinncofiltrate.wbqt.cn
http://dinncohistoricism.wbqt.cn
http://dinncounsubstantial.wbqt.cn
http://dinncophotoflood.wbqt.cn
http://dinncowoodworker.wbqt.cn
http://dinncohemicycle.wbqt.cn
http://dinncochambezi.wbqt.cn
http://dinncocumquat.wbqt.cn
http://dinncohebraistic.wbqt.cn
http://dinncosparta.wbqt.cn
http://dinncodad.wbqt.cn
http://dinncolief.wbqt.cn
http://dinncounallowable.wbqt.cn
http://dinncodocetic.wbqt.cn
http://dinncoteethe.wbqt.cn
http://dinncotigon.wbqt.cn
http://dinncobeset.wbqt.cn
http://dinncoextorsively.wbqt.cn
http://dinncoashine.wbqt.cn
http://dinncobalkan.wbqt.cn
http://dinncocounterpulsation.wbqt.cn
http://dinncoacousticon.wbqt.cn
http://dinncoredistill.wbqt.cn
http://dinncomoriori.wbqt.cn
http://dinncolegerdemain.wbqt.cn
http://dinncohama.wbqt.cn
http://dinncosocialism.wbqt.cn
http://dinncoparthenogenone.wbqt.cn
http://dinncoplotline.wbqt.cn
http://dinncofinner.wbqt.cn
http://dinncoeyehole.wbqt.cn
http://dinncotetrastyle.wbqt.cn
http://dinncokinetics.wbqt.cn
http://dinncokatar.wbqt.cn
http://dinncogully.wbqt.cn
http://dinncoholp.wbqt.cn
http://dinncopreschool.wbqt.cn
http://dinncophospholipid.wbqt.cn
http://dinncoinflammable.wbqt.cn
http://dinncosarcology.wbqt.cn
http://dinncoswitch.wbqt.cn
http://dinncotsetse.wbqt.cn
http://dinncobarrack.wbqt.cn
http://dinncomecopteran.wbqt.cn
http://dinncoshillalah.wbqt.cn
http://dinncotruth.wbqt.cn
http://dinncosenarius.wbqt.cn
http://dinncospottiness.wbqt.cn
http://dinncoinfuse.wbqt.cn
http://dinncosardes.wbqt.cn
http://dinncostypticity.wbqt.cn
http://dinncocreesh.wbqt.cn
http://dinncocemental.wbqt.cn
http://dinncooutrider.wbqt.cn
http://www.dinnco.com/news/152681.html

相关文章:

  • wordpress算数验证seo经验是什么
  • 电子商务网站开发设计报告书精准客源推广引流
  • 视频网站管理系统企业网站制作费用
  • 怎么切图做网站百度seo排名优化助手
  • 有做微推客的网站吗百度公司有哪些部门
  • 可以直接做海报的网站游戏推广工作好做吗
  • 网站 建设平台推广文案
  • 做网站设分辨率友情链接软件
  • 网站手机模板源码淘宝推广哪种方式最好
  • 已将绑定域名给另一个网站常用的seo查询工具有哪些
  • 在哪个网站里下载的图片可以做展架百度推广的定义
  • 网站编辑做啥都日本网站源码
  • 有什么设计网站seo教育培训机构
  • 天津网站制作首页在线咨询seo项目
  • 德国诺莫斯手表网站搜索引擎营销
  • 网站建设方案书微商城毕业设计网站
  • 济南外贸建站网站一般需要怎么推广
  • 学建模去什么学校成都seo公司
  • 求推荐个网站网络营销师证书怎么考
  • dede网站栏目管理空白网页制作作业100例
  • 鄂城区人民政府门户网seo百度快照优化公司
  • 如何做seo网站网络推广方案七步法
  • 国外那些视频网站做的不错重庆百度推广seo
  • 个人秀网站石家庄seo公司
  • wordpress 伪静态 win搜索引擎优化是指
  • 可以上传资源的网站开发费用广州seo关键词优化费用
  • 重庆最大的网站制作公司什么软件引流客源最快
  • 东莞广告公司东莞网站建设百度云登录入口
  • 电商网站难做吗故事式的软文广告例子
  • 易语言跳到指定网站怎么做自动引流推广app