0.2.0 • Published 2 years ago
@wholezb/filters v0.2.0
@wholezb/filters
A library project for filters
Setup
install:
npm i @wholezb/filters -S
You need to add configuration for vue-cli to correctly translate the es module in node_modules:
// vue.config.js:
module.exports = {
transpileDependencies: [
'@wholezb/*' // all of node_module for '@wholezb'
]
}
setup:
import {currency} from '@wholezb/filters';
Vue.filter('currency', currency);
usage:
<template>
<div>{{value|currency}}</div>
</template>
Filters List
scope | function | desc |
---|---|---|
Currency | currency(value:number) | Convert to currency format,e.g. '100,00.01' |
Datetime | dateformat(dateInfo:*, format:string = 'YYYY-MM-DD') | Convert to date format |
Datetime | timestr(ms:number) | Convert to time format |
physical | distance(value, fixed = 1) | Formatted distance field with unit output, The unit is 'm' when it is less than 1000, and the unit is 'km' when it is more than 1000. |
String | repeat,trim | Alias of repeat,trim in lodash |