当前位置:网站首页>How to transfer event objects and user-defined parameters simultaneously in Huawei express applications
How to transfer event objects and user-defined parameters simultaneously in Huawei express applications
2022-07-02 11:00:00 【Huawei Developer Forum】
Phenomenon description
The following methods are used in fast application js Event method of binding component , If you pass the event object and custom parameters at the same time, you will find that the parameters are not received correctly in the callback method , As shown below :
Problem code :
<template>
<!-- Only one root node is allowed in template. -->
<div class="container">
<input id="input1" type="button" value=" Jump " onclick="jump(event,1)"/>
</div>
</template>
<script>
module.exports = {
jump: function (event, v) {
console.info("e = " + JSON.stringify(event));
console.info("v = " + v);
}
}
</script>
Print the log as follows :
Problem analysis
The supported writing of event callback ( among { {}} It can be omitted ):
- "fn":fn Call back the function name for the event ( stay <script> There is a corresponding function implementation in ).
- "fn(a,b)": Function parameters, such as a,b It can be a constant , Or in <script> Of data Variables defined in ( Don't write in front this.).
- "a+b": expression , among a,b The data type is the same as above .
When the callback function is called , An... Will be automatically added at the end of the parameter list evt Parameters , adopt evt Parameter to access context data related to callback events ( Please refer to the component callback event description for the data content ), For example, click location of click event x,y.
Solution
Modify the code as follows :
<template>
<!-- Only one root node is allowed in template. -->
<div class="container">
<input id="input1" type="button" value=" Jump " onclick="jump(1)" />
</div>
</template>
<script>
module.exports = {
jump: function (v, evt) {
console.info("e = " + JSON.stringify(evt));
console.info("v = " + v);
}
}
</script>
Print the log as follows :
Introduction to fast application event binding :
边栏推荐
- Leetcode+ 76 - 80 storm search topic
- 2022爱分析· 国央企数字化厂商全景报告
- PCL之K-d树与八叉树
- 一招快速实现自定义快应用titlebar
- Internet News: Tencent conference application market was officially launched; Soul went to Hong Kong to submit the listing application
- Introduction to MySQL 8 DBA foundation tutorial
- Hdu1236 ranking (structure Sorting)
- 华为应用市场应用统计数据问题大揭秘
- 使用sqlcipher打开加密的sqlite方法
- 【快应用】Win7系统使用华为IDE无法运行和调试项目
猜你喜欢
Analysis of hot spots in AI technology industry
【深入浅出玩转FPGA学习3-----基本语法】
From Read and save in bag file Jpg pictures and PCD point cloud
[visual studio] visual studio 2019 community version cmake development environment installation (download | install relevant components | create compilation execution project | error handling)
从.bag文件中读取并保存.jpg图片和.pcd点云
【深入浅出玩转FPGA学习4----漫谈状态机设计】
How to get the password of cpolar?
【AGC】构建服务3-认证服务示例
【AppLinking实战案例】通过AppLinking分享应用内图片
快应用中实现自定义抽屉组件
随机推荐
UVM factory mechanism
Special topic of binary tree -- acwing 1497 Traversal of the tree (use post and mid order traversal to build a binary tree)
php中self和static在方法中的区别
Start class, data analysis, high salary training plan, elite class
使用sqlcipher打开加密的sqlite方法
JVM garbage collector
二叉树专题--洛谷 P3884 [JLOI2009]二叉树问题(dfs求二叉树深度 bfs求二叉树宽度 dijkstra求最短路)
【快应用】text组件里的文字很多,旁边的div样式会被拉伸如何解决
Learn open62541 -- [66] UA_ Generation method of string
华为应用市场应用统计数据问题大揭秘
[visual studio] visual studio 2019 community version cmake development environment installation (download | install relevant components | create compilation execution project | error handling)
UVM learning - object attribute of UVM phase
axis设备的rtsp setup头中的url不能带参
【深入浅出玩转FPGA学习4----漫谈状态机设计】
二叉树专题--AcWing 1589. 构建二叉搜索树
12. Process synchronization and semaphore
JS settimeout() and interview questions
【AGC】如何解决事件分析数据本地和AGC面板中显示不一致的问题?
PCL 投影点云
618再次霸榜的秘密何在?耐克最新财报给出答案