vue-directive.js 383 Bytes
/*
* @Author: Targaryen
* @Date:   2016-08-02 17:29:52
* @Last Modified by:   Targaryen
* @Last Modified time: 2016-08-02 17:42:26
*/

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);
    });
};