第一次开发web项目的时候遇到:监听浏览器回退,并执行一些方法或函数。
mounted() {
let _this = this;
// 监听浏览器回退
window.addEventListener("popstate", function (e) {
// doing
// _this.$store.commit("setShowLyric", false);
// _this.$store.commit("setShowLyric", false);
// this.alert(_this.showLyric)
});
},