我为 Chrome 创建了一个扩展程序,并在其中使用了 Vue 和 Vue-router。
我使用 router.push()
浏览页面,它工作正常。问题是我无法转换回来。
<template>
<a href="#" class="left" @click="back">
<i class="icon-fontello-left"></i>
</a>
</template>
<script>
export default {
methods: {
back(){
console.log('back click, current', this.$router.currentRoute);
this.$router.back();
}
}
}
</script>
当我点击控制台返回点击,当前对象{name: undefined, meta: Object, path: "/settings", hash: "", query: Object…}
,但是没有发生转换,没有错误。
我尝试了不同的选择:
this.$router.back()
this.$router.go(-1)
但它们都不起作用
版本:
"vue-router": "^2.7.0",
"vue": "^2.4.1"
最佳答案
您是否尝试过手动操作历史 API 以查看会发生什么?
https://developer.mozilla.org/en-US/docs/Web/API/History_API
看来您可能还需要设置权限:
https://developer.chrome.com/extensions/history不过我不确定那个,可能有助于阅读它。
关于vue.js - vue-router back()不工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47882452/