08 . Vue腳手架安裝,使用,自定義配置和Element-UI導入使用


Vue腳手架

Vue腳手架可以快速生成Vue項目基礎的架構。

安裝3.x版本的Vue腳手架
/*
			npm install -g @vue/cli@3.3
*/
基於3.3版本的腳手架命令創建Vue項目
/*

     1.  命令:vue create my-project
       		選擇Manually select features(選擇特性以創建項目)
          
     2.  勾選特性可以用空格進行勾選。
       
             ? Please pick a preset: Manually select features
             ? Check the features needed for your project: 
             ◉ Babel
             ◯ TypeScript
             ◯ Progressive Web App (PWA) Support
             ◉ Router
             ◯ Vuex
             ◯ CSS Pre-processors
            ❯◉ Linter / Formatter
             ◯ Unit Testing
             ◯ E2E Testing
       
     3.  ? Use history mode for router? (Requires proper server setup for index fallback in production) (Y/n)  n
       是否選用歷史模式的路由:n
       
     4.  ? Please pick a preset: Manually select features
          ? Check the features needed for your project: Babel, Router, Linter
          ? Use history mode for router? (Requires proper server setup for index fallback in production) No
          ? Pick a linter / formatter config: 
            ESLint with error prevention only 
            ESLint + Airbnb config 
          ❯ ESLint + Standard config 
            ESLint + Prettier 
       ESLint選擇:ESLint + Standard config
       
       
       
    5.  ? Please pick a preset: Manually select features
        ? Check the features needed for your project: Babel, Router, Linter
        ? Use history mode for router? (Requires proper server setup for index fallback in production) No
        ? Pick a linter / formatter config: Standard
        ? Pick additional lint features: (Press <space> to select, <a> to toggle all, <i> to invert selection
        )
        ❯◉ Lint on save
         ◯ Lint and fix on commit
         
       何時進行ESLint語法校驗:Lint on save
       
       
   6. ? Please pick a preset: Manually select features
      ? Check the features needed for your project: Babel, Router, Linter
      ? Use history mode for router? (Requires proper server setup for index fallback in production) No
      ? Pick a linter / formatter config: Standard
      ? Pick additional lint features: (Press <space> to select, <a> to toggle all, <i> to invert selection
      )Lint on save
      ? Where do you prefer placing config for Babel, PostCSS, ESLint, etc.? 
        In dedicated config files 
      ❯ In package.json 
       babel,postcss等配置文件如何放置:In dedicated config files(單獨使用文件進行配置)
       是否保存為模板:n
       
       
       使用哪個工具安裝包:npm
       
       cd 項目名
       npm run dev
*/

基於UI界面創建Vue項目
/*	
		   命令:vue ui
       在自動打開的創建項目網頁中配置項目信息。
*/

基於2.x的舊模板,創建Vue項目
/*
		   npm install -g @vue/cli-init
       vue init webpack my-project
*/	
分析Vue腳手架生成的項目結構
/*
			    node_modules:依賴包目錄
          public:靜態資源目錄
          src:源碼目錄
          src/assets:資源目錄
          src/components:組件目錄
          src/views:視圖組件目錄
          src/App.vue:根組件
          src/main.js:入口js
          src/router.js:路由js
          babel.config.js:babel配置文件
          .eslintrc.js:
*/

Vue腳手架的自定義配置

/*
		A.通過 package.json 進行配置 [不推薦使用]
				因為package.json主要用來管理包的配置信息, 為了方便維護,推薦將vue腳手架相關的配置,單獨定義到vue.config.js配置文件中.
        "vue":{
            "devServer":{
                "port":"9990",
                "open":true
            }
        }
    B.通過單獨的配置文件進行配置,創建vue.config.js
        module.exports = {
            devServer:{
                port:8888,
                open:true
            }
        }
*/

Element-UI簡介

Element-UI安裝

Element-UI:一套基於2.0的桌面端組件庫
官網地址:http://element-cn.eleme.io/#/zh-CN

組件庫

/*
		   npm install element-ui -S
*/
Element-UI導入使用
/*
		    import ElementUI from "element-ui";
    		import "element-ui/lib/theme-chalk/index.css";
    		
    		
    		Vue.use(ElementUI)    		
*/

// 復制一段element-ui代碼到App.vue上
<el-row>
  <el-button>默認按鈕</el-button>
  <el-button type="primary">主要按鈕</el-button>
  <el-button type="success">成功按鈕</el-button>
  <el-button type="info">信息按鈕</el-button>
  <el-button type="warning">警告按鈕</el-button>
  <el-button type="danger">危險按鈕</el-button>
</el-row>

使用請看官網文檔,很詳細

https://element.eleme.cn/#/zh-CN/component/quickstart


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM