title: TypeError: this.$route.push is not a function vue.js and Uncaught TypeError: Cannot read property 'push' of undefined
body: <p>i am getting an error like "TypeError: this.$route.push is not a function" even i tried ES6 also to bind this, still not working. whenever I click a button which is "Get Homepage Data" in about.vue it should redirect to home page.  is working but here i need to call ajax and after ajax response only it has to redirect,,, so that i am not using </p>
  
  <p>router.js</p>
  
  <pre><code>import Vue from "vue";
  import Router from "vue-router";
  import Home from "../components/Home/Home.vue";
  import About from "../components/About.vue";
  import FallBackPage from "../components/FallBackPage/FallBackPage.vue";
  import MyOrders from "../components/MyOrders/MyOrders.vue";
  
   Vue.use(Router);
  
  export function createRouter() {
    return new Router({
    mode: "history",
    routes: [
     { path: "/", component: Home },
     { path: "/about", component: About },
     { path: "/myorders", component: MyOrders },
     { path: "/*", component: FallBackPage }
    ]
   });
  }
  </code></pre>
  
  <p>main.js</p>
  
  <pre><code> import Vue from "vue";
   import App from "./App.vue";
   import { createRouter } from "./router/router.js";
  
    export function createApp() {
  
     const router = createRouter();
  
     const app = new Vue({
        router,
        render: h =&gt; h(App)
    });
  
   return { app, router };
   }
  </code></pre>
  
  <p>about.vue</p>
  
  <pre><code> &lt;template&gt;
    &lt;div&gt;
      {{ aboutText }}
       &lt;button  @click="gobackToHome"&gt;Get Homepage Data&lt;/button&gt;
    &lt;/div&gt;
  &lt;/template&gt;
  &lt;script&gt;
  export default {
     data() {
      return {
        aboutText: "About Component"
      };
    },
    method: {
       gobackToHome: function() {
  
          this.$route.push("/")
  
     // $route or $router both are not working
  
  
      }
  
      // gobackToHome: () =&gt; {
        //  this.$route.push("/")
       // }
  
     }
  
  };
  &lt;/script&gt;
  </code></pre>