創建Vue項目的步驟
阿新 • • 發佈:2018-11-15
rom code span temp 頭部 創建組 link 定義 目的
第一步:
對於要創建項目的工作目錄,要先進性管理,命令:npm init -y
第二步:
初始化webpack 包,命令:vue init webpack 自定義名稱
第三步:
在components 文件中創建組件。在創建組件時要對頁面布局進行一個規劃,可以分為頭部,底部,內容三部分。在各個部分定義組件
第四步:
在src中的router 文件中的index.js中導入components 中的子組件。
第五步:
在src中的main.js中導入elementui
命令:import ElementUI from ‘element-ui‘
import ‘element-ui/lib/theme-chalk/index.css‘
Vue.use(ElementUI)
第六步:
在APP中導入components中的大方向組件(My_Header,My_Footer),並註冊這兩個組建
命令:
export default { name: ‘App‘, components:{ MyHeader, MyFooter } }
然後在template中使用
<template> <div id="app"> <MyHeader></MyHeader> <router-view class="content"></router-view> # 中間是router-link的內容 <MyFooter></MyFooter> </div> </template>
創建Vue項目的步驟