支付宝小程序组件 -- 写一个通用的cell

本文介绍了一个通用的支付宝小程序单元格组件实现方法,通过详细示例代码展示了如何在页面中使用该组件,并响应点击事件。组件具备高度的灵活性和可复用性,适用于多种场景。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

实现效果

在这里插入图片描述

//page 页面中代码

// xx.axml
<view>
 <uic-cell title="手机号" label="详情"  isLink="{{true}}" onClick="onClick">内容</uic-cell>
</view>
// xx.js
Page({
  onClick(data){ //单元格点击事件响应
    console.log(data,'124')
  },
});
一个可以通用的支付宝小程序-单元格组件

代码链接 https://github.com/nan1010082085/ant-compoent

讲述一下支付宝小程序响应 页面的事件

//组件中 事件点击
<view class="uic-cell" id="{{title}}" onTap="handleClick"></view>
Component({
  props: {
    onClick:(data)=>{return data }  //有点击事件传递过来 则 ruturn 传递的data
  },
  methods: { //响应组件中时间点击的方法 必须在 methods中
   handleClick(evt){
     this.props.onClick(evt);  //传递 props 中暴露的 方法 
   }
  },
});

//页面中 使用组件props 暴露出的参数
<uic-cell title="手机" label="詳情" onClick="onClick">内容</uic-cell>
能不能在代码中帮我增加动态申请蓝牙权限的相关代码,在打开蓝牙适配器的时候,增加蓝牙权限的动态申请功能;这是源代码<template> <view> <view class="uni-list"> <!-- 隐藏画布,用于标签绘制 --> <canvas :id="canvasId" :canvas-id="canvasId" type="2d" :style="{ width: labelWidth + 'px', height: labelHeight + 'px' }" style="position: fixed; left: -999999rpx; top: -999999rpx" /> <!-- 打印机列表 --> <view class="uni-list-cell"> <view class="uni-list-cell-left">打印机:</view> <view class="uni-list-cell-db"> <picker :value="deviceIndex" :range="deviceList" @change="onDeviceChanged" range-key="name"> <view class="uni-input">{{ deviceList[deviceIndex].name }}</view> </picker> </view> </view> </view> <view class="uni-padding-wrap uni-common-mt"> <!-- 设备搜索 --> <button type="primary" @click="startDiscovery">开始搜索打印机</button> <button type="primary" @click="stopDiscovery">停止搜索打印机</button> <!-- 链接打印机 --> <button type="primary" @click="openPrinter">打开打印机</button> <button type="primary" @click="closePrinter">关闭打印机</button> <!-- 标签编辑及打印 --> <button type="primary" plain="true" @click="onPrintTest">打印测试</button> </view> <view style="text-align: center; padding: 10px"> <view style="margin: 10px; border: solid lightgray 1px"> <image v-for="item in previewList" :src="item.value" :key="item.key" class="image" mode="widthFix" style="margin: 10rpx; border: dashed lightgray 1px" /> </view> </view> </view> </template> <script> import { LPAPIFactory, LPA_Result, LPAUtils } from "@/uni_modules/dothan-lpapi-ble/js_sdk/index.js"; // export default { data() { return { canvasId: "lpapi-ble-uni1", labelWidth: 960, labelHeight: 960, deviceList: [{ name: "未检测到打印机" }], deviceIndex: 0, isAppPlus: false, isWeiXin: false, isLark: false, isAlipay: false, isDingTalk: false, /** * 图片预览列表 * @type {{value: string; key: string;}[]} ***/ previewList: [], threshold: 128, }; }, onLoad() { consol
最新发布
04-02
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值