在html里面
{{ money | toChies }}
在script里面
<script>
import CommonMixin from '@/mixins/common-mixin'
export default {
filters:{
toChies (values) {
let len = values.length
let arr = []
let chinList = [
'零',
'壹',
'贰',
'叁',
'肆',
'伍',
'陆',
'柒',
'捌',
'玖'
]
let chinLisp = [
'仟',
'佰',
'拾',
'亿',
'仟',
'佰',
'拾',
'万',
'仟',
'佰',
'拾'
]
for (let i = 0; i < len; i++) {
arr.push(parseInt(values[i], 10))
arr[i] = chinList[arr[i]]
}
for (let i = len - 1, j = 1; i > 0; i--) {
arr.splice(i, 0, chinLisp[chinLisp.length - j++])
}
arr = arr.join('')
if (len >= 1) {
arr += '元整'
}
return arr
},
}
}
</script>