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

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

parent e290fc27
...@@ -229,6 +229,7 @@ export default { ...@@ -229,6 +229,7 @@ export default {
this.init(lang) this.init(lang)
}, },
mounted: function () { mounted: function () {
this.preloadTabImages();
this.init2(); this.init2();
}, },
data() { data() {
...@@ -297,10 +298,20 @@ export default { ...@@ -297,10 +298,20 @@ export default {
this.activeTab = tab; this.activeTab = tab;
$(".input-sm").attr("placeholder", placeholder[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) { getTabImage(tab) {
return this.activeTab === tab return this.activeTab === tab ? this.tabImages[tab].B : this.tabImages[tab].A
? this.tabImages[tab].B
: this.tabImages[tab].A;
}, },
init: function (lang) { 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