2020年6月17日

初步学习next.js-7-打包

摘要: "scripts": { "dev": "next dev", "build": "next build", "start": "next start -p 80" }, 如果引入antd的样式,打包会报错!删除按需引入的antd样式 在page目录下,新建一个_app.js文件,_app.js文件 阅读全文

posted @ 2020-06-17 14:05 秃了头也不退休 阅读(1531) 评论(0) 推荐(0) 编辑

初步学习next.js-6-使用antd

摘要: 首先需要让next支持css文件 yarn add @zeit/next-css 建立一个next.config.js const withCss = require('@zeit/next-css') if(typeof require !== 'undefined'){ require.exte 阅读全文

posted @ 2020-06-17 13:59 秃了头也不退休 阅读(328) 评论(0) 推荐(0) 编辑

初步学习next.js-5-编写css样式和lazyloading

摘要: CSS import React, {useState} from 'react' function Jspang(){ //关键代码 start const [color,setColor] = useState('blue') const changeColor=()=>{ setColor(c 阅读全文

posted @ 2020-06-17 13:43 秃了头也不退休 阅读(387) 评论(0) 推荐(0) 编辑

初步学习next.js-4-在getInitialProps中用axios获取数据

摘要: yarn add axios import axios from 'axios' const Page = ({ stars }) => <div> Next stars: {stars} </div> Page.getInitialProps = async ({ req }) => { cons 阅读全文

posted @ 2020-06-17 13:39 秃了头也不退休 阅读(959) 评论(0) 推荐(0) 编辑

初步学习next.js-3-6个路由钩子

摘要: import React from 'react' import Link from 'next/link' import Router from 'next/router' const Home = () => { function gotoXiaojiejie(){ Router.push({ 阅读全文

posted @ 2020-06-17 13:36 秃了头也不退休 阅读(618) 评论(0) 推荐(0) 编辑

初步学习next.js-2-组件,路由,传递参数

摘要: pages和components 1.直接在根目录下的pages文件夹下,新建一个jsyang.js页面,启动后 访问路径为/jsyang 2.在根目录下新建文件夹components,新建组件com1.js文件, export default ({children})=><button>{chil 阅读全文

posted @ 2020-06-17 11:45 秃了头也不退休 阅读(2561) 评论(0) 推荐(0) 编辑

初步学习next.js-1-新建项目

摘要: react和vue做的都是单页面应用 缺点:1.不适合SEO 2.启动慢 解决方案:next.js 参考技术胖的资料进行学习 https://jspang.com/detailed?id=51#toc21 1.手动创建next.js 创建文件夹 D: mkdir NextDemo npm init 阅读全文

posted @ 2020-06-17 11:29 秃了头也不退休 阅读(843) 评论(0) 推荐(0) 编辑

导航