当前位置:网站首页>If the uniapp is less than 1000, it will be displayed according to the original number. If the number exceeds 1000, it will be converted into 10w+ 1.3k+ display
If the uniapp is less than 1000, it will be displayed according to the original number. If the number exceeds 1000, it will be converted into 10w+ 1.3k+ display
2022-07-04 10:06:00 【gblfy】

List of articles
1. Public methods
methods: {
// Number conversion
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. Use
page
<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;"> Be praised </text>
</view>
</template>
Method area
methods: {
// Put more than 1000 or 10000 Digital adjustment of , such as 1.3k/6.8w
getGraceNumber(num) {
return getApp().graceNumber(num);
},
}
边栏推荐
- Write a jison parser from scratch (2/10): learn the correct posture of the parser generator parser generator
- 浅谈Multus CNI
- MySQL case
- 入职中国平安三周年的一些总结
- Golang defer
- uniapp 小于1000 按原数字显示 超过1000 数字换算成10w+ 1.3k+ 显示
- Write a jison parser from scratch (5/10): a brief introduction to the working principle of jison parser syntax
- Golang 类型比较
- Work order management system OTRs
- Hands on deep learning (III) -- Torch Operation (sorting out documents in detail)
猜你喜欢

技术管理进阶——如何设计并跟进不同层级同学的绩效

Devop basic command

智能网关助力提高工业数据采集和利用

六月份阶段性大总结之Doris/Clickhouse/Hudi一网打尽

基于线性函数近似的安全强化学习 Safe RL with Linear Function Approximation 翻译 1

Dynamic address book

Hands on deep learning (III) -- Torch Operation (sorting out documents in detail)

用数据告诉你高考最难的省份是哪里!

华为联机对战如何提升玩家匹配成功几率

SQL replying to comments
随机推荐
What is devsecops? Definitions, processes, frameworks and best practices for 2022
Svg image quoted from CodeChina
pcl::fromROSMsg报警告Failed to find match for field ‘intensity‘.
转载:等比数列的求和公式,及其推导过程
MATLAB小技巧(25)竞争神经网络与SOM神经网络
Exercise 9-3 plane vector addition (15 points)
[200 opencv routines] 218 Multi line italic text watermark
Write a jison parser from scratch (6/10): parse, not define syntax
A little feeling
Servlet基本原理与常见API方法的应用
How web pages interact with applets
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
Hands on deep learning (33) -- style transfer
Exercise 9-5 address book sorting (20 points)
C语言指针经典面试题——第一弹
浅谈Multus CNI
Advanced technology management - how to design and follow up the performance of students at different levels
自动化的优点有哪些?
Golang Modules
Four common methods of copying object attributes (summarize the highest efficiency)