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

export default (Vue) => {
    Vue.directive('lazy-html', {
        bind(el, binding) {
            // TODO 首屏幕不使用
            let html = binding.value
                .replace(/<img [^>]*src=['"]([^'"]+)[^>]*>/gi, '<img v-bind:src="\'$1\'">')
                .replace(/https?:/gi, '');

            this.el.innerHTML = html;
            // this.vm.$compile(this.el);
        }
    });
};