我的 vue 组件是这样的:
<template>
<span class="rating">
...
</span>
</template>
<script>
export default {
props: {
'star': null
},
...
}
</script>
如果组件正在运行,我想禁用浏览器中返回的按钮。所以用户无法返回到上一页
我该怎么做?
最佳答案
尝试这个脚本,添加到您创建 vue 实例的 html 文件中
history.pushState(null, null, location.href);
window.onpopstate = function () {
history.go(1);
};
关于vue.js - 如何使用 vue 组件禁用浏览器上的后退按钮?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45541789/