Commit 27a85c12 authored by Tang Xinwei's avatar Tang Xinwei

减少切换按钮的延迟,进入页面就读取全按钮

parent e290fc27
......@@ -229,6 +229,7 @@ export default {
this.init(lang)
},
mounted: function () {
this.preloadTabImages();
this.init2();
},
data() {
......@@ -297,10 +298,20 @@ export default {
this.activeTab = tab;
$(".input-sm").attr("placeholder", placeholder[tab]);
},
preloadTabImages() {
const imgs = []
Object.values(this.tabImages).forEach(({A, B}) => {
[A, B].forEach(src => {
const im = new Image()
im.src = src
imgs.push(im)
})
})
// Keep a reference so GC doesn’t drop them immediately
this._preloaded = imgs
},
getTabImage(tab) {
return this.activeTab === tab
? this.tabImages[tab].B
: this.tabImages[tab].A;
return this.activeTab === tab ? this.tabImages[tab].B : this.tabImages[tab].A
},
init: function (lang) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment