随笔分类 -  next.js

next-定义路由
摘要:在next.config.js里写 const withCss = require('@zeit/next-css') if(typeof require !== 'undefined'){ require.extensions['.css']=file=>{} } module.exports = 阅读全文

posted @ 2020-09-02 17:09 秃了头也不退休 阅读(382) 评论(0) 推荐(0)

next-支持css样式和按需加载antd
摘要:yarn add @zeit/next-css 在blog根目录下,新建一个next.config.js文件。这个就是Next.js的总配置文件。写入下面的代码: const withCss = require('@zeit/next-css') if(typeof require !== 'und 阅读全文

posted @ 2020-09-02 11:28 秃了头也不退休 阅读(1017) 评论(0) 推荐(0)

nginx
摘要:优点 支持海量高并发(官方说是5W个) 内存消耗少 免费使用可以商业化 配置文件简单 安装 $ yarn create nuxt-app <项目名> 目录结构 |-- .nuxt // Nuxt自动生成,临时的用于编辑的文件,build |-- assets // 用于组织未编译的静态资源入LESS 阅读全文

posted @ 2020-06-28 11:52 秃了头也不退休 阅读(153) 评论(0) 推荐(0)

初步学习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 秃了头也不退休 阅读(1611) 评论(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 秃了头也不退休 阅读(352) 评论(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 秃了头也不退休 阅读(399) 评论(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 秃了头也不退休 阅读(980) 评论(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 秃了头也不退休 阅读(634) 评论(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 秃了头也不退休 阅读(2666) 评论(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 秃了头也不退休 阅读(918) 评论(0) 推荐(0)

导航