Vue 學習過程

Global install

//首先安裝主題工具
npm i element-theme -g


用于安裝element ui,并且改變主題

//安裝elementui
npm i element-ui -S
//安裝sass,用于改變主題
npm i sass-loader node-sass -D
//首先安裝主題工具
npm i element-theme -g
//然后安裝chalk主題
npm i element-theme-chalk -D

//console
// 初始化變量文件
et -i [可以自定義變量文件,默認為element-variables.scss]

> ? Generator variables file

//生成的文件修改變量
$--color-primary: purple;

//console 編譯
et

//main.js
import '../theme/index.css'
import ElementUI from 'element-ui'
import Vue from 'vue'

Vue.use(ElementUI)

傳遞事件

  1. 全局變化 vuex

  2. 子組件傳遞到父組件

   this.$emit("小寫的時間名稱",傳遞的參數(shù)對象{})


   @小寫事件名稱="父組件事件" 
   this.$on("小寫的時間名稱",function(參數(shù)對象){}

  1. 同級別的組件之間傳遞事件
// bus.js定義一個全局的變量
import Vue from 'vue'

export default new Vue()
 
//調(diào)用事件
bus.$emit('auth')

//全局監(jiān)聽,或者同級的組件監(jiān)聽
import bus from './util/bus'
bus.$on('auth', () => {
  router.push('/login')
})

最后編輯于
?著作權歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務。

友情鏈接更多精彩內(nèi)容