Does the vue encapsulate the fallback function to report an error?

fallback is a common function, so I encapsulated it as a global function

//assetes/global.js
import Vue from "vue"
import Router from "vue-router";
Vue.use(Router)

export default({
    //
    back:function(){
        this.$router.go(-1); //
    },
})

error message is Cannot read property "go" of undefined

so I wrote it differently:

Router.$router.go(-1);

still report an error, how to solve it?


you can call the method


//main.jsVUE
window.VUE = new Vue({
  el: '-sharpapp',
  router,
  store,
  components: { App },
  template: '<App/>'
})
//assetes/global.jsback
VUE.$router.go(-1);
only if you refer to the Router instantiated by your project through new .
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b31f68-2bdbe.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b31f68-2bdbe.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?