perf: 去除临时变量 _this

根据箭头函数特点,直接使用 this,无需创建临时变量
This commit is contained in:
YangFong 2022-08-10 13:30:07 +08:00
parent 392ae673f3
commit 774a5f32f8
1 changed files with 17 additions and 18 deletions

View File

@ -65,11 +65,10 @@
}) })
}, },
contextMenuVisible(value) { contextMenuVisible(value) {
var _this = this; const cm = (e) => {
var cm = function(e){ const sp = document.getElementById("contextmenu");
let sp = document.getElementById("contextmenu");
if (sp && !sp.contains(e.target)) { if (sp && !sp.contains(e.target)) {
_this.closeMenu() this.closeMenu()
} }
} }
if (value) { if (value) {
@ -161,23 +160,23 @@
}, },
//TAB //TAB
refreshTab() { refreshTab() {
var nowTag = this.contextMenuItem;
this.contextMenuVisible = false this.contextMenuVisible = false
const nowTag = this.contextMenuItem;
// //
if(this.$route.fullPath != nowTag.fullPath){ if (this.$route.fullPath !== nowTag.fullPath) {
this.$router.push({ this.$router.push({
path: nowTag.fullPath, path: nowTag.fullPath,
query: nowTag.query query: nowTag.query
}) })
} }
this.$store.commit("refreshIframe", nowTag) this.$store.commit("refreshIframe", nowTag)
var _this = this; setTimeout(() => {
setTimeout(function() { this.$store.commit("removeKeepLive", nowTag.name)
_this.$store.commit("removeKeepLive", nowTag.name) this.$store.commit("setRouteShow", false)
_this.$store.commit("setRouteShow", false) this.$nextTick(() => {
_this.$nextTick(() => { this.$store.commit("pushKeepLive", nowTag.name)
_this.$store.commit("pushKeepLive",nowTag.name) this.$store.commit("setRouteShow", true)
_this.$store.commit("setRouteShow", true)
}) })
}, 0); }, 0);
}, },