• 小程序事件绑定介绍


    小程序事件绑定介绍

    1.介绍我们可以给元素绑定事件,但是绑定的事件函数不能传递参数,如果想要传递参数,可以自定义属性到元素或者组件上,值作为传递的数据

    <!-- 
    
        1.bind:事件名称="事件处理程序" 
    
        bind绑定的事件会有冒泡的行为
    
    -->
    
    
    <input data-name="name" bind:input="inputVal"type="text" />
    
    
    <!-- 
    
        2.catch:事件名称="事件处理程序"
    
        catch绑定的事件不会有冒泡的行为
     -->
    
    <input data-name="name" catch:input="inputVal2"type="text" />
    
    
    <!-- 事件捕获机制绑定事件 -->
    
    
    <input data-name="name" capture-bind:input="inputVal3"type="text" />
    
    
    <input data-name="name" capture-catch:input="inputVal4"type="text" />
    Page({
    
        inputVal (event) {
        
            // 通过事件对象可以拿到元素上自定义属性值的数据
            console.log(event)
        },
    }
  • 相关阅读:
    topcoder srm 681 div1
    topcoder srm 683 div1
    topcoder srm 684 div1
    topcoder srm 715 div1
    topcoder srm 685 div1
    topcoder srm 687 div1
    topcoder srm 688 div1
    topcoder srm 689 div1
    topcoder srm 686 div1
    topcoder srm 690 div1 -3
  • 原文地址:https://www.cnblogs.com/zxuedong/p/12910247.html
Copyright © 2020-2023  润新知