vue-filter.js
453 Bytes
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];
});
});