detail.page.js 904 Bytes
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(/src\s*=['|"]\s*(.*)['|"]/gi, 'v-lazy="\'$1\'"');
    this.el.innerHTML = html;
    this.vm.$compile(this.el);
});

new Vue({
    el: '#app',
    components: {
        app: app
    }
});