uniapp中List列表绑值

<template>
	<view class="u-page">
		<u-cell-group class="font">
			<u-cell icon="phone-fill" v-for="(item, index) in data" :key="index" :title="'姓名:'+item.compellation" >
				<template slot='label'>
					<view style="margin: 2rpx;" @click="callPhone(item.phone)">联系电话:{{item.phone}}</view>
					<view style="margin: 2rpx;">备用电话:{{item.standbyPhone}}</view>
				</template>
			</u-cell>
		</u-cell-group>
	</view>
</template>
<script>
	import * as api from '@/request';
	export default {
		name: 'index',
		data() {
			return {
				data:[],
			};
		},
		onLoad() {
			this.data = []
			this.getInfo()
		},
		methods: {
			getInfo() {
				let params = {
					data:{},
					pageNum: 1,
					pageSize: 10,
				}
				api.complaintAll(params).then(res => {
					this.data = this.data.concat(res.data.list)
					console.log('列表:',this.data)
					uni.stopPullDownRefresh()
				});
			},
			// 拨打电话
			callPhone(phone){
				uni.makePhoneCall({
					phoneNumber:phone
				})
			}
		}
	};
</script>

<style scoped lang="scss">
</style>

🍉  import * as api from '@/request';    

       将 @/request 模块中的所有导出内容进行整体导入(引入)的方式。这样我们可以在其他模块中直接使用 api 对象来访问 @/request 中导出的所有函数和变量。

🍉   this.data = [ ]        //将数组清空

🍉   this.getInfo()        //重新获取数据并更新页面

🍉   this.data = this.data.concat(res.data.list)        

        concat() 方法将新获取到的数据拼接到已有的数据列表中,更新 this.data的值

🍉  uni.stopPullDownRefresh()       //uni.stopPullDownRefresh() 方法停止下拉刷新动画

🍉  uni.makePhoneCall({ phoneNumber:phone })        //点击电话号码可以直接拨打电话

页面效果展示:

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
uni-app,可以使用v-on指令来绑定点击事件。具体做法是在需要绑定点击事件的元素上添加v-on:click属性,并将其值设置为一个方法名。当该元素被点击时,对应的方法会被调用。例如,给一个按钮绑定点击事件的代码如下所示: <template> <view> <button type="primary" v-on:click="clickHandle()">按钮</button> </view> </template> <script> export default { data() { return {} }, methods: { clickHandle() { console.log('点击我了') } } } </script> <span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* [uni-app双击事件(单击、双击互不干扰)](https://blog.csdn.net/qq_44046765/article/details/114582406)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 33.333333333333336%"] - *2* [解决vue 绑定对象内点击事件失效问题](https://download.csdn.net/download/weixin_38516863/12952799)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 33.333333333333336%"] - *3* [uniapp 绑定事件](https://blog.csdn.net/weixin_57607714/article/details/118520251)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 33.333333333333336%"] [ .reference_list ]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值