uniapp实现table排序

根据后端接口传来的数字大小对列表进行升序/降序展示

效果图,价格由高到低降序

价格由低到高 升序

js 降序升序代码如下

复制代码
	export default {
		data() {
			return {
                    MtList:[]
                    }
                },
        onLoad() {
			        this.MtypeName();//加载列表方法
		        },
		methods: {
                MtypeName(){//列表方法
				this.$api.getTypeNameUserID({
					 ctime1:this.ctime3,
					 ctime2:this.ctime4,
				}).then(res => {//allmoney 金额
				     this.MtList = res.result.sort((a,b)=>b.allmoney-a.allmoney);//降序
                     //this.MtList = res.result.sort((a,b)=>a.allmoney-b.allmoney);//升序
				})
			},
                   }

wxml 代码

复制代码
<view class="typeClassDiv">
	<view class="typeListClass" v-for="(m,index) in MtList" @click="typeBut(m.typename,m.allmoney,m.bCount)">
	 <image :src="m.typeLogo" class="tyLogo"></image>
	 <view class="tyContent">
			 <view class="tytop"><text class='typeNameClass'>{{m.typename}}</text><text class='typeMClass'>{{m.bfb}}%({{m.bCount}}笔)</text></view>
				 <view class="tybottom">
					 <view class="progress-box">
			    <progress style="padding-top: 10px;padding-left: 2px;" :percent="m.bfb" stroke-width="3"/>
			 </view>
		 </view>
			 </view>
		 <view class="tyFont">
		 	¥{{m.allmoney}}
		  </view>
	  </view>
</view>

小程序日常记一记 分析页面 可参考

相关推荐
CHB10 小时前
uni-ai:让你的App快速接入AI
uni-app·deepseek
小徐_23332 天前
uni-app vue3 也能使用 Echarts?Wot Starter 是这样做的!
前端·uni-app·echarts
iOS阿玮2 天前
永远不要站在用户的对立面,挑战大众的公知。
uni-app·app·apple
xw53 天前
uni-app中v-if使用”异常”
前端·uni-app
!win !3 天前
uni-app中v-if使用”异常”
前端·uni-app
2501_915918413 天前
iOS 上架全流程指南 iOS 应用发布步骤、App Store 上架流程、uni-app 打包上传 ipa 与审核实战经验分享
android·ios·小程序·uni-app·cocoa·iphone·webview
00后程序员张3 天前
iOS App 混淆与加固对比 源码混淆与ipa文件混淆的区别、iOS代码保护与应用安全场景最佳实践
android·安全·ios·小程序·uni-app·iphone·webview
00后程序员张3 天前
详细解析苹果iOS应用上架到App Store的完整步骤与指南
android·ios·小程序·https·uni-app·iphone·webview
海绵宝宝不喜欢侬3 天前
uniapp-微信小程序分享功能-onShareAppMessage
微信小程序·小程序·uni-app
2501_915106323 天前
Xcode 上传 ipa 全流程详解 App Store 上架流程、uni-app 生成 ipa 文件上传与审核指南
android·macos·ios·小程序·uni-app·iphone·xcode