Search code examples
nativescript-vue

How to use Manual Routing inside Vuex actions?


I am trying to use $navigateTo function inside Vuex actions

  • _this.$navigateTo is not a function.

  • Vue.prototype.$navigateTo(Test) is also pointless since you can't navigate between components.

  • $navigateTo does not exist in Vuex.Store

How to navigate with Vuex actions nativescipt-vue?


import Vue from "vue";
import Vuex from "vuex";
import Test from "./components/Test.vue";

Vue.use(Vuex);

export default new Vuex.Store({
  actions: {
    go() {
      this.$navigateTo(Test); 
//Property '$navigateTo' does not exist on type 'Store<unknown>'.
    }
  }
});

Please check out my repo It navigates to test page even it has an empty password

https://github.com/kaanguru/vuexnavigate

https://nativescript-vue.org/en/docs/routing/manual-routing/#navigatetocomponent-options


Solution

  • It turns out Vue.prototype.$navigateTo(Test) was the correct answer

    Vue.prototype.$navigateTo(Test) is also pointless since you can't navigate between components.
    

    No, it's not pointless you can navigate between components.