当前位置:网站首页>uniapp 小于1000 按原数字显示 超过1000 数字换算成10w+ 1.3k+ 显示
uniapp 小于1000 按原数字显示 超过1000 数字换算成10w+ 1.3k+ 显示
2022-07-04 09:36:00 【gblfy】

1. 公共方法
methods: {
// 数字换算
graceNumber(number) {
if (number == 0) {
return "0";
} else if (number > 999 && number <= 9999) {
return (number / 1000).toFixed(1) + 'k';
} else if (number > 9999 && number <= 99999) {
return (number / 10000).toFixed(1) + 'w';
} else if (number > 99999) {
return "10w+";
}
return number;
},
}
2. 使用
页面
<template>
<view @click="openMask()"
style="margin-left: 50rpx;display: flex;flex-direction: column;justify-content: center;">
<text
style="color: #ffffff;font-size: 14px;font-weight: bold;align-self: center;">{
{
getGraceNumber(pageUserInfo.totalLikeMeCounts)}}</text>
<text style="color: #ffffff;font-size: 12px;font-weight: 300;align-self: center;">获赞</text>
</view>
</template>
方法区
methods: {
// 把超过1000或10000的数字调整,比如1.3k/6.8w
getGraceNumber(num) {
return getApp().graceNumber(num);
},
}
边栏推荐
- The child container margin top acts on the parent container
- PHP personal album management system source code, realizes album classification and album grouping, as well as album image management. The database adopts Mysql to realize the login and registration f
- Kotlin 集合操作汇总
- Launpad | Basics
- Intelligent gateway helps improve industrial data acquisition and utilization
- 查看CSDN个人资源下载明细
- Pcl:: fromrosmsg alarm failed to find match for field 'intensity'
- 什么是 DevSecOps?2022 年的定义、流程、框架和最佳实践
- 回复评论的sql
- Hands on deep learning (38) -- realize RNN from scratch
猜你喜欢

2022-2028 global strain gauge pressure sensor industry research and trend analysis report

Dynamic memory management
Web端自动化测试失败原因汇总

PHP student achievement management system, the database uses mysql, including source code and database SQL files, with the login management function of students and teachers

Leetcode (Sword finger offer) - 35 Replication of complex linked list

5g/4g wireless networking scheme for brand chain stores

Normal vector point cloud rotation

Matlab tips (25) competitive neural network and SOM neural network

品牌连锁店5G/4G无线组网方案

Hands on deep learning (III) -- Torch Operation (sorting out documents in detail)
随机推荐
Kotlin set operation summary
2022-2028 global industrial gasket plate heat exchanger industry research and trend analysis report
【leetcode】29. Divide two numbers
IIS configure FTP website
PHP student achievement management system, the database uses mysql, including source code and database SQL files, with the login management function of students and teachers
Exercise 9-5 address book sorting (20 points)
Sort out the power node, Mr. Wang he's SSM integration steps
PHP personal album management system source code, realizes album classification and album grouping, as well as album image management. The database adopts Mysql to realize the login and registration f
Hands on deep learning (35) -- text preprocessing (NLP)
Advanced technology management - how to design and follow up the performance of students at different levels
直方图均衡化
C # use ffmpeg for audio transcoding
Four common methods of copying object attributes (summarize the highest efficiency)
技术管理进阶——如何设计并跟进不同层级同学的绩效
Hands on deep learning (36) -- language model and data set
In the case of easyUI DataGrid paging, click the small triangle icon in the header to reorder all the data in the database
Rules for using init in golang
MATLAB小技巧(25)竞争神经网络与SOM神经网络
Write a jison parser from scratch (3/10): a good beginning is half the success -- "politics" (Aristotle)
Vanishing numbers