Nativescript-Vue:加载Vuex时出现“ TNS预览”错误?

时间:2020-02-03 19:40:43

标签: vue.js vuex nativescript-vue tns

对于我正在为移动设备开发的琐事应用程序,我正在使用Nativescript-Vue进行开发。使用xcode iOS模拟器运行时,该应用程序运行良好且没有错误。但是,当我尝试运行预览(使用终端命令:“ tns Preview”)时,该应用会运行,但是当我尝试启动游戏时,该应用会引发错误:

CONSOLE ERROR file:///app/tns_modules/nativescript-vue/dist/index.js:2129:20: [Vue warn]: Error in render: "TypeError: undefined is not an object (evaluating 'this.$store.getters')"

found in

---> <App> at App.vue
       <Frame>
        <Root>
LOG from device iPhone CONSOLE ERROR file:///app/tns_modules/nativescript-vue/dist/index.js:2129:20: [Vue warn]: Error in nextTick: "TypeError: undefined is not an object (evaluating 'this.$store.getters')"

我正在尝试使用iPhone SE上的运动场应用程序运行它并扫描二维码。我在想这与应用程序无法访问VueX商店有关。但是我有点茫然。我已经看过'tns Preview'命令的工作原理,但这是在没有Vuex的Vue应用程序中进行的。你知道我可能做错了吗?

更新:在main.js中添加Vue.prototype.$store = store后,我得到一个略有不同的错误:

CONSOLE ERROR file:///app/tns_modules/nativescript-vue/dist/index.js:2129:20: [Vue warn]: Error in render: "TypeError: this.$store.getters is not an Object. (evaluating 'val in this.$store.getters')"

仍然不知道可能出什么问题,但是我确实知道tns预览在禁用/注释代码中与商店相关的所有内容时都可以使用,因此肯定与此有关。请帮忙,我真的很想在手机上向别人展示这个应用程序。

1 个答案:

答案 0 :(得分:0)

在导入商店之后,我通过在main.js中添加以下行来解决了这个问题:

import store from './store'
Vue.prototype.$store = store