【发布时间】:2020-09-16 08:30:57
【问题描述】:
我无法以编程方式更新主题。它会更新,但需要刷新才能显示主题更新。我试过使用 location.reload();在更新时刷新页面。这行不通。
我使用 Vue 构建应用程序。
我目前正在将我的商店导入 vuetify 插件。
import Vue from "vue";
import Vuetify from "vuetify/lib";
import store from "./../store";
Vue.use(Vuetify);
let theme = store.getters.THEME;
export default new Vuetify({
theme: {
themes: {
light: {
primary: theme.primary,
secondary: theme.secondary,
accent: theme.accent,
error: theme.error
}
}
}
});
我设置了使用 axios 从服务器返回的主题变量。
setTheme() {
this.$http
.get(`organisations/${this.organisation}`)
.then(response => {
this.$store.dispatch("SET_THEME", response.data.organisation.theme);
})
.catch(e => {
this.errors.push(e);
});
}
一切正常,甚至奇怪的是我存储在同一个 vuex 状态对象中的徽标更新。
state: {
auth: {},
user: {},
organisation: {},
theme: {
primary: "#00ACC1",
secondary: "#84FFFF",
accent: "#80CBC4",
error: "#EF9A9A",
logo: ""
},
settings: {},
rules: [],
rulesFinal: {},
journey: "main",
selectedTable: {},
selectedOrder: {},
selectedCategory: {}
},
但是,即使同一对象中的徽标动态更新,我设置的颜色也不会。是否有我遗漏的东西或某种强制 vuetify 更新的方法?
我现在尝试了三种不同的方法,如果能得到任何帮助,我将不胜感激。
【问题讨论】:
标签: vue.js vuex vuetify.js