ty-mobile-uni
Version:
uView UI,是uni-app生态优秀的UI框架,全面的组件和便捷的工具会让您信手拈来,如鱼得水
32 lines (31 loc) • 842 B
JavaScript
import theme from '../theme.scss';
export default {
data() {
return {
mainColor:this.getThemeObj().colorMain||"#608df5",
}
},
watch:{
'$store.state.theme.theme'(val) {
this.mainColor=this.getThemeObj().colorMain||"#608df5";
}
},
methods:{
getThemeObj(){
const themeStore=this.$store&&this.$store.state.theme;
if(themeStore){//项目中设置有皮肤
const themeObj=themeStore.themeObj;
return themeObj[themeStore.theme];
}
else{//没有就用系统默认皮肤
return theme;
}
},
//hex 转 rgba
hexToRgba(hex, opacity) {
return hex && hex.replace(/\s+/g, '').length === 7 ? 'rgba(' + parseInt('0x' + hex.slice(1, 3)) + ',' +
parseInt('0x' + hex.slice(3, 5)) + ',' +
parseInt('0x' + hex.slice(5, 7)) + ',' + opacity + ')' : ''
},
}
}