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)
傳遞事件
全局變化 vuex
子組件傳遞到父組件
this.$emit("小寫的時間名稱",傳遞的參數(shù)對象{})
@小寫事件名稱="父組件事件"
this.$on("小寫的時間名稱",function(參數(shù)對象){}
- 同級別的組件之間傳遞事件
// 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')
})