Authored by ccbikai

商品详情页面优化

... ... @@ -5,10 +5,10 @@
* @Last Modified time: 2016-08-02 17:42:26
*/
let Vue = require('vue');
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);
});
module.exports = (Vue) => {
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);
});
};
... ...
const Vue = require('vue');
const lazyload = require('vue-lazyload');
const app = require('editorial/detail.vue');
const directive = require('common/vue-directive');
const app = require('product/detail/index.vue');
require('common/vue-filter');
require('common/vue-directive');
Vue.use(lazyload);
Vue.use(directive);
new Vue({
el: '#app',
... ...
const Vue = require('vue');
const $ = require('jquery');
const app = require('product/detail/index.vue');
const loading = require('common/loading');
const lazyload = require('vue-lazyload');
const directive = require('common/vue-directive');
const app = require('product/detail/index.vue');
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);
});
Vue.use(directive);
new Vue({
el: '#app',
... ...