当前位置:网站首页>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
- 自动化的优点有哪些?
- Exercise 9-4 finding books (20 points)
- PHP is used to add, modify and delete movie information, which is divided into foreground management and background management. Foreground users can browse information and post messages, and backgroun
- 查看CSDN个人资源下载明细
- Machine learning -- neural network (IV): BP neural network
- Golang defer
- Web端自动化测试失败原因汇总
- Fabric of kubernetes CNI plug-in
- Lauchpad X | 模式
猜你喜欢
xxl-job惊艳的设计,怎能叫人不爱
Intelligent gateway helps improve industrial data acquisition and utilization
Daughter love: frequency spectrum analysis of a piece of music
SSM online examination system source code, database using mysql, online examination system, fully functional, randomly generated question bank, supporting a variety of question types, students, teache
C语言指针经典面试题——第一弹
QTreeView+自定义Model实现示例
How web pages interact with applets
The child container margin top acts on the parent container
2022-2028 global seeder industry research and trend analysis report
Daughter love in lunch box
随机推荐
el-table单选并隐藏全选框
How web pages interact with applets
`Example of mask ` tool use
Log cannot be recorded after log4net is deployed to the server
Hands on deep learning (44) -- seq2seq principle and Implementation
对于程序员来说,伤害力度最大的话。。。
Luogu deep foundation part 1 Introduction to language Chapter 4 loop structure programming (2022.02.14)
2022-2028 global gasket plate heat exchanger industry research and trend analysis report
What are the advantages of automation?
Kotlin: collection use
SSM online examination system source code, database using mysql, online examination system, fully functional, randomly generated question bank, supporting a variety of question types, students, teache
Write a mobile date selector component by yourself
2022-2028 global industry research and trend analysis report on anterior segment and fundus OTC detectors
Write a jison parser (7/10) from scratch: the iterative development process of the parser generator 'parser generator'
Golang Modules
品牌连锁店5G/4G无线组网方案
【leetcode】540. A single element in an ordered array
libmysqlclient. so. 20: cannot open shared object file: No such file or directory
Baidu R & D suffered Waterloo on three sides: I was stunned by the interviewer's set of combination punches on the spot
Advanced technology management - how to design and follow up the performance of students at different levels