detail.page.js
915 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
const Vue = require('vue');
const $ = require('jquery');
const app = require('product/detail/index.vue');
const loading = require('common/loading');
const lazyload = require('vue-lazyload');
require('common/vue-filter');
require('common/overlay');
Vue.use(lazyload);
(() => {
let stop = 0;
$(document).ajaxStart(()=> {
// start = new Date().getTime();
// setTimeout(()=> {
if (stop === 0) { // 超过100ms请求仍未结束则显示
loading.show();
}
// }, 100);
});
$(document).ajaxStop(()=> {
stop = new Date().getTime();
loading.hide();
});
})();
Vue.directive('lazy-html', function(html) {
html = html.replace(/<img [^>]*src=['"]([^'"]+)[^>]*>/gi, '<img v-lazy="\'$1\'">');
this.el.innerHTML = html;
this.vm.$compile(this.el);
});
new Vue({
el: '#app',
components: {
app: app
}
});