0.2.0 • Published 2 years ago

@wholezb/filters v0.2.0

Weekly downloads
-
License
MIT
Repository
-
Last release
2 years ago

@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

scopefunctiondesc
Currencycurrency(value:number)Convert to currency format,e.g. '100,00.01'
Datetimedateformat(dateInfo:*, format:string = 'YYYY-MM-DD')Convert to date format
Datetimetimestr(ms:number)Convert to time format
physicaldistance(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.
Stringrepeat,trimAlias of repeat,trim in lodash