uniapp父子传点击事件
发布日期:2021-06-29 01:52:49
浏览次数:2
分类:技术文章
本文共 3355 字,大约阅读时间需要 11 分钟。
1.写一个简单的子组件main/index.vue:
在子组件中有一个childMethod方法
2.在父组件中引用这个子组件的childMethod方法:
button
(一)子组件---->父组件
子组件(发送) (1)绑定@click, (2)在return定义数据名, (3)methods方法中进行传递。 例://view中
//js的return中 return:{ title:'son'}
//在methods中进行传值
methods:{ click(){ this.$emit('change',this.title) }}
父组件(接收)
(1)绑定事件, (2)在return定义数据名, (3)methods方法中进行接收。 例://view中
//js的return中 return:{ title:''}
//在methods中进行接收
methods:{ change(res){ console.log(res) this.title=res }}
(一)父组件---->子组件
父组件(发送) (1)绑定数据, (2)在return定义数据名, 例://view中
//js的return中 return:{ text:"i am father"}
子组件(接收)
(1)绑定数据, (2)在props定义数据名, 例://view中
{ { text}} //js的props中 props:['text'] //或者text:{ type:String //定义类型 default:"" //默认值 }
完整的
//这是父组件的东西//子组件的 按钮 支付方式 余额支付 (余额0元) 微信支付 确定
样式
子组件样式@import '/static/css/font_icon.css';.res_tk { box-sizing: border-box; background-color: rgba(0, 0, 0, 0.5); position: fixed; top: 0; left: 0; height: 100vh; width: 750rpx; z-index: 2001;}.tk_bs { box-sizing: border-box; position: absolute; bottom: 0; left: 0; background-color: #FFFFFF; width: 750rpx; border-radius: 20rpx 20rpx 0px 0px; animation-iteration-count: 1; animation: mymove2 0.3s; -webkit-animation-iteration-count: 1; backface-visibility: hidden;}@keyframes mymove2 { 0% { transform: translate(0rpx, 100vh) } 100% { transform: translate(0rpx, -0vh) }}@-webkit-keyframes mymove2 { 0% { transform: translate(0rpx, 100vh) } 100% { transform: translate(0rpx, -0vh) }}.bts { width: 750rpx; height: 100rpx; text-align: center; line-height: 100rpx;}.bt_h1 { color: #333333; font-size: 40rpx;}.Xx_xxi { width: 20rpx; height: 36rpx; margin: 36rpx 8rpx 0 0; position: absolute; top: 0; right: 24rpx; display: flex; justify-content: center; align-items: center;}.nei_x1 { transform: rotate(45deg); width: 20rox; height: 100%; border: 2rpx solid #666666;}.nei_x2 { margin: 0 0 0 -4rpx; transform: rotate(-45deg); width: 20rox; height: 100%; border: 2rpx solid #666666;}.order { width: 750rpx; display: flex; align-items: center; justify-content: space-between; box-sizing: border-box; border-bottom: 2rpx solid #F4F4F4; padding: 34rpx 24rpx; color: #333333; font-size: 28rpx;}.order_img { width: 44rpx; height: 44rpx; padding: 0 10rpx 0 0;}.order_yellow { font-size: 24rpx; color: #EA3323;}.bt_qd { width: 460rpx; height: 34rpx; background: #4F77E1; border-radius: 40rpx; margin: 40rpx auto; padding: 20rpx 0; font-size: 32rpx; color: #FFFFFF;}.reason_active { width: 24rpx; height: 24rpx; background-color: #FFFFFF; border: 2rpx solid #999999; border-radius: 50% 50%;}.flex_a{ display: flex; justify-content: space-between; align-items: center;}.flex_b{ display: flex; justify-content: center; align-items: center;}.flex_d{ display: flex; align-items: center;}
转载地址:https://blog.csdn.net/YUlangML/article/details/117703372 如侵犯您的版权,请留言回复原文章的地址,我们会给您删除此文章,给您带来不便请您谅解!
发表评论
最新留言
不错!
[***.144.177.141]2024年04月14日 09时58分21秒
关于作者
喝酒易醉,品茶养心,人生如梦,品茶悟道,何以解忧?唯有杜康!
-- 愿君每日到此一游!
推荐文章
大家都知道Python库很强大,却不知道还有强大工具包 poetry? ...
2019-04-29
《TCP IP 详解卷1:协议》阅读笔记 - 第十六章
2019-04-29
编程在哪学,可以免费自学编程的10个网站
2019-04-29
蓝桥杯2013年JavaB组
2019-04-29
Lambda简单示例
2019-04-29
BootStrap4登录表单验证示例
2019-04-29
划重点—2020年CCSP的考试大纲有这些变化
2019-04-29
测一测|企业信息安全管理10道小题你能答对几个?
2019-04-29
信息安全意识主题分享-数据安全
2019-04-29
请收下这份CCSP云安全专家认证备考攻略(合集)
2019-04-29
一文带你了解PDPF隐私与数据保护认证
2019-04-29
WireShark网络安全分析
2019-04-29
【备考干货】一次拿下CISM认证的经验分享
2019-04-29
疫情之下看我如何调整心态拿下CISM认证
2019-04-29
2020年Security+备考经验分享
2019-04-29
工具集电子书等4G资料免费分享(IT 信安菜鸟入门必备)
2019-04-29
备考干货「三」CISM(国际注册信息安全经理)考过笔记
2019-04-29
大学生有哪些信息安全认证可以考?
2019-04-29
2020年Security+备考经验分享(二)
2019-04-29
ITIL4,全球IT行业抢手的资格认证之一
2019-04-29