用来对商品价格数值的小数点前后部分应用不同样式,还支持人民币符号、千位分隔符、设置小数点位数等功能。
效果
使用方法
<template> <div class="demo-list"> <lc-title title="商品价格"></lc-title> <category title="基本用法"></category> <p>无人民币符号,有千位分隔</p> <div> <lc-cell> <span slot="title"> <lc-price :price="1010" :needSymbol="false" :thousands="true"/> </span> </lc-cell> </div> <p>带人民币符号,无千位分隔</p> <div> <lc-cell> <span slot="title"> <lc-price :price="10010.01" :needSymbol="true" :thousands="false"/> </span> </lc-cell> </div> <p>带人民币符号,有千位分隔,保留小数点后三位</p> <div> <lc-cell> <span slot="title"> <lc-price :price="15213.1221" :decimalDigits="3" :needSymbol="true" :thousands="true"/> </span> </lc-cell> </div> </div> </template>
<script> import LcTitle from '_mods/title.vue'; import Category from '_mods/category.vue'; export default { components: { LcTitle, Category }, }; </script>
<style lang="less" scoped> .demo-con { padding-left: 20px; margin-bottom: 40px; } p{ line-height: 26px; padding:10px; font-size: 14px;} </style>
|
可配置参数
字段 |
说明 |
类型 |
默认值 |
price |
价格数量 |
Number |
0 |
needSymbol |
是否需要加上人民币符号 |
Boolean |
true |
decimalDigits |
小数位位数 |
Number |
2 |
thousands |
是否按照千分号形式显示 |
Boolean |
false |