1. 创建项目
安装 create-nuxt-app,这是创建nuxt项目的脚手架
1 | npm install -g create-nuxt-app |
使用脚手架创建项目 create-nuxt-app <项目名>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21> create-nuxt-app hello
? Project name hello
? Project description My super Nuxt.js project
? Use a custom server framework express
? Choose features to install Axios
? Use a custom UI framework element-ui
? Use a custom test framework none
? Choose rendering mode Single Page App
? Author name panchaoxin
? Choose a package manager npm
To get started:
cd hello
npm run dev
To build & start for production:
cd hello
npm run build
npm start
还要安装一些基本依赖1
2
3cnpm i css-loader -D
cnpm i node-less -D
cnpm i less-loader -D
2. 项目目录结构
参考官方:https://zh.nuxtjs.org/guide/directory-structure
assets和static目录的区别:这两个目录都是存放静态资源的,webpack会编译assets中的静态资源,但是不会编译static中的静态资源