vue.js - Vuex 商店参考 Vuetify -“TypeError:无法读取未定义的属性‘主题’”
问题描述
我想从 vuex 商店更改 vuetify 的道具。从我可以做的一个组件this.$vuetify.theme.dark = true;
。这在商店中是不可能的,但不幸的是,我在尝试时遇到了同样的错误Vue.prototype.$vuetify.theme.dark = true;
。
我得到的错误是Error in v-on handler: "TypeError: Cannot read property 'theme' of undefined"
.
在我的 main.js 中,我有以下内容:
Vue.use(Vuetify);
const vuetify = new Vuetify({
theme: {
dark: true,
themes: {
light: {
primary: colors.purple,
secondary: colors.grey.darken1,
accent: colors.shades.black,
error: colors.red.accent3,
background: colors.indigo.lighten5, // Added variable
},
dark: {
primary: colors.blue.lighten3,
// If using base color, be use to mark as such to get HEX value
background: colors.indigo.base,
},
},
},
});
new Vue({
router,
store,
vuetify,
render: (h) => h(App),
}).$mount('#app');
我发现 $vuetify 未定义很奇怪,因为我尝试了类似的东西Vue.prototype.$socket.emit('my_event', { data: 'I\'m connected!' });
并且这有效。
这里可能是什么错误?
解决方案
推荐阅读
- mongodb - 使用 Cosmic Clone 克隆集合时出错
- javascript - 在 php 中显示谷歌地图
- json - 如何在复选框选择/取消选择时生成复杂 json 列表
- angular - 在 api 请求角度中添加变量
- r - 减少 barplot 中 names.arg 和轴(框)之间的空间
- python - C#(使用 WPF)服务器和 Python 客户端之间的套接字
- java - 每当可观察列表 JavaFX 的对象发生更改时更新表视图 UI
- c++ - 链接的设计模式
- reactjs - 如何在没有 UI 的情况下对钩子进行 Jest 测试
- r - 为什么在 DT 包中,当 escaping=FALSE 和 hyperkink href target=_blank 时,datatable 函数在 markdown HTML 中不起作用,但在 Shiny 中运行良好?