VUE簡單整理

在用 Vue.js 構建大型應用時推薦使用 NPM 安裝:html

# 最新穩定版 $ cnpm install vue

命令行工具

Vue.js 提供一個官方命令行工具,可用於快速搭建大型單頁應用。vue

# 全局安裝 vue-cli $ cnpm install --global vue-cli # 建立一個基於 webpack 模板的新項目 $ vue init webpack my-project # 這裏須要進行一些配置,默認回車便可 This will install Vue 2.x version of the template. For Vue 1.x use: vue init webpack#1.0 my-project ? Project name my-project ? Project description A Vue.js project ? Author ***** <test@dongpouu.com> ? Vue build standalone ? Use ESLint to lint your code? Yes ? Pick an ESLint preset Standard ? Setup unit tests with Karma + Mocha? Yes ? Setup e2e tests with Nightwatch? Yes vue-cli · Generated "my-project". To get started: cd my-project npm install npm run dev Documentation can be found at https://vuejs-templates.github.io/webpack

進入項目,安裝並運行:node

$ cd my-project $ cnpm install $ cnpm run dev DONE Compiled successfully in 4388ms > Listening at http://localhost:8080

成功執行以上命令後訪問 http://localhost:8080/,輸出結果以下所示:webpack

注意:Vue.js 不支持 IE8 及其如下 IE 版本。git

 

目錄解析

目錄/文件 說明
build 項目構建(webpack)相關代碼
config 配置目錄,包括端口號等。咱們初學能夠使用默認的。
node_modules npm 加載的項目依賴模塊
src

這裏是咱們要開發的目錄,基本上要作的事情都在這個目錄裏。裏面包含了幾個目錄及文件:github

  • assets: 放置一些圖片,如logo等。
  • components: 目錄裏面放了一個組件文件,能夠不用。
  • App.vue: 項目入口文件,咱們也能夠直接將組件寫這裏,而不使用 components 目錄。
  • main.js: 項目的核心文件。
static 靜態資源目錄,如圖片、字體等。
test 初始測試目錄,可刪除
.xxxx文件 這些是一些配置文件,包括語法配置,git配置等。
index.html 首頁入口文件,你能夠添加一些 meta 信息或統計代碼啥的。
package.json 項目配置文件。
README.md 項目的說明文檔,markdown 格式
相關文章
相關標籤/搜索