Nuxt是什么?
Nuxt是基于Vuejs的一套服务端渲染框架,Nuxt中不仅仅有Vuejs,还集成了Vuex等等。Nuxt主要关注的是应用的UI渲染。
使用
初始化项目
1 | npx create-nuxt-app <my-project> |
or1
npm init nuxt-app <my-project>
or1
yarn create nuxt-app <my-project>
运行
1 | yarn run dev |
打包
1 | yarn run build |
部署
1 | yarn start |
使用插件
ElementUI
安装1
2
3yarn add element-ui
// or
npm install element-ui --save
在plugin目录下创建element-ui.js文件1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23import Vue from 'vue'
import {
Button,
Loading,
Row,
Col,
Container,
Aside,
Main
} from 'element-ui' // 可按需引入你需要的组件
// 注意:如果打包时也要按需引入还需要安装babel-plugin-component插件
// 直接 yarn add babel-plugin-component --dev 安装
// 并使用Vue.use方法使用它们
Vue.use(Button)
Vue.use(Row)
Vue.use(Col)
Vue.use(Container)
Vue.use(Aside)
Vue.use(Main)
Vue.prototype.$loading = Loading.service // 在Vue对象的原型上直接声明loading组件属性
1 | { |