博客列表 >uni常用的事件

uni常用的事件

default
default原创
2022年02月19日 16:34:49718浏览
  1. <template>
  2. <view class="content">
  3. <view class="" >
  4. <input
  5. style="background: #008000;"
  6. type="text"
  7. @input="input"
  8. @blur="blur()"
  9. @focus="focus()"
  10. @confirm="confirm"
  11. @click="click"
  12. @tap="tap"
  13. @longpress="logpress()"
  14. >
  15. <br>
  16. <br>
  17. <br>
  18. <br>
  19. <button type="default"
  20. @touchstart="touchstart"
  21. @touchend="touchend"
  22. @touchmove="touchmove"
  23. @touchcancel="touchcancel"
  24. >触摸测试 </button>
  25. </view>
  26. </view>
  27. </template>
  28. <script>
  29. export default {
  30. data() {
  31. return {}
  32. },
  33. methods: {
  34. input(){
  35. console.log("input的val")
  36. },
  37. blur(){
  38. console.log("失去了焦点")
  39. },
  40. focus(){
  41. console.log("获取了焦点")
  42. },
  43. confirm(){
  44. console.log('回车')
  45. },
  46. click(){
  47. console.log('单机事件')
  48. },
  49. tap(){
  50. //手机端的触摸事件优先级比click高
  51. console.log('手机端的点击事件')
  52. },
  53. logpress(){
  54. console.log('手机端的长按事件')
  55. },
  56. touchstart(){
  57. console.log('触摸开始')
  58. },
  59. touchend(){
  60. console.log('触摸结束')
  61. },
  62. touchmove(){
  63. console.log('触摸移动')
  64. },
  65. touchcancel(){
  66. console.log('触摸被打断')
  67. }
  68. }
  69. }
  70. </script>
  71. <style>
  72. </style>
声明:本文内容转载自脚本之家,由网友自发贡献,版权归原作者所有,如您发现涉嫌抄袭侵权,请联系admin@php.cn 核实处理。
全部评论
文明上网理性发言,请遵守新闻评论服务协议