• This project
    • Loading...
  • Sign in

fe / yohoblk-wap · Files

Go to a project

GitLab

  • Go to group
  • Project
  • Activity
  • Files
  • Commits
  • Pipelines 0
  • Builds 0
  • Graphs
  • Milestones
  • Issues 0
  • Merge Requests 0
  • Members
  • Labels
  • Wiki
  • Forks
  • Network
  • Create a new issue
  • yohoblk-wap
  • public
  • js
  • common
  • vue-filter.js
  • 完善 focus
    4c4ebd88
    by ccbikai
    2016-07-19 18:07:21 +0800  
    Browse Files
vue-filter.js 453 Bytes
Raw Blame History Permalink
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
let Vue = require('yoho-vue');


/**
 * 替换参数
 *
 * @example
 *   value = /{width}/{height}/{model}
 *
 *   {value | resize 100 200 2}  ==> /100/200/2
 */
Vue.filter('resize', (value, width, height, model)=>{
    return value.replace(/({width}|{height}|{mode})/g, function($0) {
        const dict = {
            '{width}': width,
            '{height}': height,
            '{mode}': model || 2
        };

        return dict[$0];
    });
});