1.vue環境搭建
阿新 • • 發佈:2018-12-16
- 下載node
類似下載QQ一樣,下一步,下一步…注意新增到環境變數
//cmd命令視窗 node -v //看看node版本 以及檢測是否安裝好 v8.11.3 npm -v //安裝node會自帶包管理工具 5.6.0
- 全域性安裝vue-cli腳手架
npm install vue-cli -g
- 安裝好後,命令列輸入vue 看看是不是安裝成功
//表示安裝成功 C:\Users\Administrator>vue Usage: vue <command> [options] Options: -V, --version output the version number -
- 建立vue專案
vue init webpack [project-name]//專案名稱不能中文 不可大寫 不可與資料夾名稱一樣 PS C:\Users\Administrator\Desktop\code\node> vue init webpack vue-demo ? Project name vue-demo ? Project description A Vue.js project ? Author ? Vue build standalone ? Install vue-router? No //第一次學習建議全no(下同) ? Use ESLint to lint your code?
- 目錄結構分析
//一個vue元件,裡面對應有template script 和style 使得vue元件開發特別容易上手
<template> //類似html
<div id="app">
<img src="./assets/logo.png">
<HelloWorld/>
</div>
</template>
<script> //類似script
import HelloWorld from './components/HelloWorld'
export default {
name: 'App',
components: {
HelloWorld
}
}
</script>
<style> //類似樣式
#app {
font-family: 'Avenir', Helvetica, Arial, sans-serif;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
text-align: center;
color: #2c3e50;
margin-top: 60px;
}
</style>