1
1
---
2
- title : 安装
2
+ 安装
3
3
description : Nuxt.js 十分简单易用。一个简单的项目只需将 `nuxt` 添加为依赖组件即可。
4
4
---
5
5
6
6
> Nuxt.js 十分简单易用。一个简单的项目只需将 ` nuxt ` 添加为依赖组件即可。
7
7
8
- ## 新手模板
8
+ ## 运行 create-nuxt-app
9
9
10
- 为了便于大家快速使用 ,Nuxt.js提供了一个 [ starter 模板 ] ( https://github.com/nuxt-community/starter-template ) 。
10
+ 为了快速入门 ,Nuxt.js团队创建了脚手架工具 [ create-nuxt-app ] ( https://github.com/nuxt/create-nuxt-app ) 。
11
11
12
- [ 下载模板的压缩包 ] ( https://github.com/nuxt-community/starter-template/archive/master.zip ) 或利用 ` vue-cli ` 安装使用 :
12
+ 确保安装了npx(npx在NPM版本5.2.0默认安装了) :
13
13
14
14
``` bash
15
- $ vue init nuxt-community/starter-template < project-name >
15
+ $ npx create- nuxt-app < 项目名 >
16
16
```
17
17
18
- > 如果 [ Vue CLI] ( https://github.com/vuejs/vue-cli ) 没有安装, 需先通过 ` npm install -g @vue/cli @vue/cli-init ` 来安装。
19
-
20
- 然后安装依赖包:
18
+ 或者用yarn :
21
19
22
20
``` bash
23
- $ cd < project-name>
24
- $ npm install
21
+ $ yarn create-nuxt-app < 项目名>
25
22
```
26
23
27
- 接着通过以下命令启动项目:
24
+ 它会让你进行一些选择:
25
+
26
+ 1 . 在集成的服务器端框架之间进行选择:
27
+ - None (Nuxt默认服务器)
28
+ - [ Express] ( https://github.com/expressjs/express )
29
+ - [ Koa] ( https://github.com/koajs/koa )
30
+ - [ Hapi] ( https://github.com/hapijs/hapi )
31
+ - [ Feathers] ( https://github.com/feathersjs/feathers )
32
+ - [ Micro] ( https://github.com/zeit/micro )
33
+ - [ Adonis] ( https://github.com/adonisjs/adonis-framework ) (WIP)
34
+ 2 . 选择您喜欢的UI框架:
35
+ - None (无)
36
+ - [ Bootstrap] ( https://github.com/bootstrap-vue/bootstrap-vue )
37
+ - [ Vuetify] ( https://github.com/vuetifyjs/vuetify )
38
+ - [ Bulma] ( https://github.com/jgthms/bulma )
39
+ - [ Tailwind] ( https://github.com/tailwindcss/tailwindcss )
40
+ - [ Element UI] ( https://github.com/ElemeFE/element )
41
+ - [ Buefy] ( https://buefy.github.io )
42
+ 3 . 选择你想要的Nuxt模式 (` Universal ` or ` SPA ` )
43
+ 4 . 添加 [ axios module] ( https://github.com/nuxt-community/axios-module ) 以轻松地将HTTP请求发送到您的应用程序中。
44
+ 5 . 添加 [ EsLint] ( https://eslint.org/ ) 以在保存时代码规范和错误检查您的代码。
45
+ 5 . 添加 [ Prettier] ( https://prettier.io/ ) 以在保存时格式化/美化您的代码。
46
+
47
+ 当运行完时,它将安装所有依赖项,因此下一步是启动项目:
48
+
28
49
``` bash
29
50
$ npm run dev
30
51
```
31
- 应用现在运行在 http://localhost:3000
32
52
33
- <p class =" Alert " >注意:Nuxt.js 会监听 `pages` 目录中的文件变更并自动重启, 当添加新页面时没有必要手工重启应用。</p >
53
+ 应用现在运行在 http://localhost:3000 上运行。
54
+
55
+ <p class =" Alert " >注意:Nuxt.js 会监听 `pages` 目录中的文件更改,因此在添加新页面时无需重新启动应用程序。</p >
34
56
35
57
了解模板项目的目录结构: [ 目录结构] ( /guide/directory-structure ) 。
36
58
@@ -43,7 +65,7 @@ $ mkdir <项目名>
43
65
$ cd < 项目名>
44
66
```
45
67
46
- * 提示: 将 项目名 替换成为你想创建的实际项目名*
68
+ < p class = " Alert Alert--nuxt-green " >< b > 提示:</ b > 将 < code > & lt ; 项目名& gt ; </ nom-du-projet ></ code > 替换成为你想创建的实际项目名。</ p >
47
69
48
70
### 新建 package.json 文件
49
71
@@ -85,8 +107,8 @@ $ mkdir pages
85
107
``` bash
86
108
$ npm run dev
87
109
```
88
- Bingo! 现在我们的应用运行在 http://localhost:3000
110
+ 现在我们的应用运行在 http://localhost:3000 上运行。
89
111
90
- <p class =" Alert " >注意:Nuxt.js 会监听 `pages` 目录中的文件变更并自动重启, 当添加新页面时没有必要手工重启应用 。</p >
112
+ <p class =" Alert " >注意:Nuxt.js 会监听 `pages` 目录中的文件更改,因此在添加新页面时无需重新启动应用程序 。</p >
91
113
92
114
了解更多关于Nuxt.js应用的目录结构: [ 目录结构] ( /guide/directory-structure ) 。
0 commit comments