1 echart圖表
昨天已經(jīng)成功引入了echart,今天主要是做把從服務(wù)端獲取的數(shù)據(jù)渲染上去
dataset:{
source:this.deviceList //這是服務(wù)端數(shù)據(jù)[{value: "0", date: "2020-08-14 16:34:47", deviceid: "5f1d65ed23f3756af19022eb",…},...]
},
series: [{
name: this.chartTitle,
type: 'line',
encode:{x:'date',y:'value'} //x軸對應(yīng)的數(shù)據(jù)為:dataset中數(shù)組中,鍵為date的值
//此處也可用下標(biāo)如x:0,來對應(yīng),但由于鍵值對是無序的,用鍵獲取數(shù)據(jù)更不容易出錯(cuò)
}]
2 菜單權(quán)限
1 在登錄成功后,將該用戶對應(yīng)的菜單存入store中
2 用路由的導(dǎo)航守衛(wèi),在跳轉(zhuǎn)路由時(shí),進(jìn)行攔截(main.js)
router.beforeEach((to, from, next) => {
if(to.name !== 'login' && to.name !== 'index'){
if(store.state.menuList==""){//還未登錄沒有初始化有權(quán)限的菜單項(xiàng)時(shí),返回到登錄頁
next({ path: '/' })
}else{//判斷當(dāng)前賬號有無此菜單權(quán)限,有則繼續(xù),無則返回到登錄頁并提示錯(cuò)誤
var isAuthenticated = store.state.menuList.some(item=>item.path == to.path)
if(isAuthenticated){
next()
}else{
next({path:'/'})
Httputils.showToast(0,'地址錯(cuò)誤或沒有訪問權(quán)限')
}
}
}else{//不需要進(jìn)行權(quán)限判斷的頁面,直接跳轉(zhuǎn)路由
next()
}
})