vue-directive.js 362 Bytes
/*
* @Author: Targaryen
* @Date:   2016-08-02 17:29:52
* @Last Modified by:   Targaryen
* @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);
});