vue-cli PC端構建
阿新 • • 發佈:2018-08-12
loader 保存狀態 imp cli 還需 create sas color use
1 # 全局安裝 vue-cli 2 npm install --global vue-cli //首次安裝需要 3 # 創建一個基於 webpack 模板的新項目 4 vue init webpack my-project 5 # 安裝依賴,走你 6 cd my-project 7 npm install//使用cnpm install代替 8 npm run dev
localhost:8080查看
安裝axios npm install axios --save //如報錯,使用淘寶鏡像 cnpm install axios --save
項目main.js中引入 import axios from‘axios‘ Vue.prototype.$http = axios
1 安裝element 2 3 npm i element-ui -S 4 //如報錯,使用下面安裝 5 cnpm i element-ui -S 6 7 8 項目main.js中引入 9 10 import ElementUI from ‘element-ui‘ 11 import ‘element-ui/lib/theme-chalk/index.css‘ 12 Vue.use(ElementUI); 13 14 15 16 安裝echarts 17 18 cnpm install echarts -S19 20 21 項目main.js中引入 22 23 import echarts from ‘echarts‘ 24 Vue.prototype.$echarts = echarts 25 26 27 安裝jquery 28 29 cnpm install jquery --save-dev 30 31 32 33 項目main.js中引入 34 35 import $ from ‘jquery‘ 36 37 38 39 安裝vuex 40 41 npm i vuex -S 42 或者 43 cnpm i vuex -s 44 45 46 使用vuex 47 48import Vue from ‘vue‘ 49 import Vuex from ‘vuex‘ 50 51 Vue.use(Vuex) 52 53 刷新保持vuex狀態 54 55 npm install vuex-persistedstate 56 57 58 使用 59 60 import createPersistedState from ‘vuex-persistedstate‘ 61 export default new Vuex.Store({ 62 state, 63 getters, 64 actions, 65 mutations, 66 plugins: [createPersistedState()]//此行為保存狀態 67 }); 68 69 70 安裝SAAS 71 72 npm install sass-loader --save-dev 73 還需要安裝 74 npm install node-sass --save-dev
vue-cli PC端構建