定义

方法名 定义 备注
number
format (value [, opt={fixed:-1,comma:false,plus:false}]) fixed为小数位,comma为千位符,plus为显示正负,det为默认值
decimal (value [, fixed]) 取小数点后的部分,fixed为小数位
upperCase (value) 中文大写数字
date
format (value [, fmt='yyyy-MM-dd hh:mm:ss']) fmt为日期格式
relativeDate (value) 相对时间
today 今天
startTime (value) 某天的开始时间
endTime (value) 某天的结束时间
weekStartTime (value) 本周的开始时间
weekEndTime (value) 本周的结束时间
monthStartTime (value) 本月的开始时间
monthEndTime (value) 本月的结束时间
yearStartTime (value) 本年的开始时间
yearEndTime (value) 本年的结束时间
timeSpanSecond (start, end) 时间相差秒数
timeSpanMinute (start, end) 时间相差分钟数
timeSpanHour (start, end) 时间相差小时数
timeSpanDay (start, end) 时间相差日数

number

format

<div>'100.1234' -> '{{ $paiui.number.format('100.1234') }}'</div>
<div>'0' -> '{{ $paiui.number.format('0') }}'</div>
<div>'0001234' -> '{{ $paiui.number.format('0001234') }}'</div>
<div>'00.123' -> '{{ $paiui.number.format('00.123') }}'</div>
<div>'...1234' -> '{{ $paiui.number.format('...1234') }}'</div>
<div>'.1.2..3' -> '{{ $paiui.number.format('.1.2..3') }}'</div>
<div>'123..31' -> '{{ $paiui.number.format('123..31') }}'</div>
<div>'abc' -> '{{ $paiui.number.format('abc') }}'</div>
<div>'123abc' -> '{{ $paiui.number.format('123abc') }}'</div>
<div>'abc123' -> '{{ $paiui.number.format('abc123') }}'</div>
<div>'-1a2b3c2.34' -> '{{ $paiui.number.format('-1a2b3c2.34') }}'</div>
<div>'123.0000' -> '{{ $paiui.number.format('123.0000') }}'</div>
<div>'123.0012' -> '{{ $paiui.number.format('123.0012') }}'</div>
<div>'123.' -> '{{ $paiui.number.format('123.') }}'</div>

fixed

<div>'123.5678' -> '{{ $paiui.number.format('123.5678', { fixed: 1 }) }}'</div>
<div>'123.5678' -> '{{ $paiui.number.format('123.5678', { fixed: 2 }) }}'</div>
<div>'123.5678' -> '{{ $paiui.number.format('123.5678', { fixed: 6 }) }}'</div>

comma

<div>'123456789.1234' -> '{{ $paiui.number.format('123456789.1234', { comma: true }) }}'</div>
<div>'-123456789.1234' -> '{{ $paiui.number.format('-123456789.1234', { comma: true }) }}'</div>

plus

<div>'1234.5678' -> '{{ $paiui.number.format('1234.5678', { plus: true }) }}'</div>
<div>'-1234.5678' -> '{{ $paiui.number.format('-1234.5678', { plus: true }) }}'</div>

more

<div>'-123456--789.01-2.3' -> '{{ $paiui.number.format('-123456--789.01-2.3', { fixed: 2, comma: true, plus: true }) }}'</div>
<div>'123456--789.01-2.3' -> '{{ $paiui.number.format('123456--789.01-2.3', { fixed: 2, comma: true, plus: true }) }}'</div>

decimal

<div>100.2345 -> '{{ $paiui.number.decimal(100.1234) }}'</div>
<div>'100.1200' -> '{{ $paiui.number.decimal('100.1200') }}'</div>
<div>100 -> '{{ $paiui.number.decimal(100) }}'</div>
<div>0.1 -> '{{ $paiui.number.decimal(0.1) }}'</div>

fixed

<div>100.2356 -> '{{ $paiui.number.decimal(100.2356, 2) }}'</div>
<div>100 -> '{{ $paiui.number.decimal(100, 2) }}'</div>

more

<div>undefined -> '{{ $paiui.number.decimal(undefined) }}'</div>

upperCase

<div>1234.56 -> '{{ $paiui.number.upperCase(1234.56) }}'</div>

date

format

<div>'' -> '{{ '' | $paiui.date('', '') }}'</div>
<div>new Date() -> '{{ $paiui.date.format(new Date()) }}'</div>
<div>1595992527161 -> '{{ $paiui.date.format(1595992527161) }}'</div>
<div>'2012-03-17' -> '{{ $paiui.date.format('2012-03-17') }}'</div>
<div>'2012/03/17' -> '{{ $paiui.date.format('2012/03/17') }}'</div>
<div>new Date() -> '{{ $paiui.date.format(new Date(), 'yyyy/MM/dd hh:mm') }}'</div>
<div>new Date() -> '{{ $paiui.date.format(new Date(), 'yyyy/MM/dd D') }}'</div>
<div>new Date() -> '{{ $paiui.date.format(new Date(), 'hh:mm:ss S') }}'</div>
<div>new Date('2019/07/01 01:02:03') -> '{{ $paiui.date.format(new Date('2019/07/01 01:02:03'), 'yy-M-d h:m:s') }}'</div>

relativeDate

<div>
    {{ $paiui.date.relativeDate(new Date()) }}
</div>
<div>
    {{ $paiui.date.relativeDate(new Date() - 1000 * 60) }}
</div>
<div>
    {{ $paiui.date.relativeDate(new Date() - 1000 * 60 * 5) }}
</div>
<div>
    {{ $paiui.date.relativeDate(new Date() - 1000 * 60 * 30) }}
</div>
<div>
    {{ $paiui.date.relativeDate(new Date() - 1000 * 60 * 60) }}
</div>
<div>
    {{ $paiui.date.relativeDate(new Date() - 1000 * 60 * 60 * 24) }}
</div>
<div>
    {{ $paiui.date.relativeDate(new Date() - 1000 * 60 * 60 * 24 * 3) }}
</div>
<div>
    {{ $paiui.date.relativeDate(new Date() - 1000 * 60 * 60 * 24 * 4) }}
</div>

today

<div>
    {{ $paiui.date.today('yyyy-MM-dd hh:mm:ss') }}
</div>

startTime and endTime

<div>
    {{ $paiui.date.startTime(new Date(), 'yyyy-MM-dd hh:mm:ss') }}
</div>
<div>
    {{ $paiui.date.endTime(new Date(), 'yyyy-MM-dd hh:mm:ss') }}
</div>

weekStartTime and weekEndTime

<div>
    {{ $paiui.date.weekStartTime(new Date(), 'yyyy-MM-dd hh:mm:ss') }}
</div>
<div>
    {{ $paiui.date.weekEndTime(new Date(), 'yyyy-MM-dd hh:mm:ss') }}
</div>

monthStartTime and monthEndTime

<div>
    {{ $paiui.date.monthStartTime(new Date(), 'yyyy-MM-dd hh:mm:ss') }}
</div>
<div>
    {{ $paiui.date.monthEndTime(new Date(), 'yyyy-MM-dd hh:mm:ss') }}
</div>

yearStartTime and yearEndTime

<div>
    {{ $paiui.date.yearStartTime(new Date(), 'yyyy-MM-dd hh:mm:ss') }}
</div>
<div>
    {{ $paiui.date.yearEndTime(new Date(), 'yyyy-MM-dd hh:mm:ss') }}
</div>

timeSpanSecond

<div>
  {{ $paiui.date.timeSpanSecond(new Date() - 1200 * 1000, new Date()) }} seconds
</div>

timeSpanMinute

<div>
  {{ $paiui.date.timeSpanMinute(new Date() - 12 * 1000 * 60, new Date()) }} minutes
</div>

timeSpanHour

<div>
  {{ $paiui.date.timeSpanHour(new Date() - 26 * 1000 * 60 * 60, new Date()) }} hours
</div>

timeSpanDay

<div>
  {{ $paiui.date.timeSpanDay(new Date() - 12 * 1000 * 60 * 60 * 24, new Date()) }} days
</div>
文档更新时间: 2021-05-12 18:38   作者:管理员