小程序实战三之微信组件事件及函数传参

项目地址

表单

input表单

  
    表单
  
  
    
  
  
    
  
  
    
  
  
    
  


其他表单

  
    其他表单
  
  
    
       呵呵
       妈妈
      爸爸
    
  
  
    
      苹果
      
    
  
  
    你好
  


表单绑定事件和传参

cbChanged(e){
    console.log(e.detail.value + " : " + e.target.dataset.aa)
},
rbChanged(e){
    console.log(e.detail.value + " : " + e.target.dataset.index)
}

wxs 微信页面的脚本程序


 //module是必要属性

  var inSum = function(a,b){
    return a + b
  }

  module.exports.sum = inSum


{{  obj.sum(1,2)  }}


或者


    module.exports={
        yaoming:function(){
        return '姚明'
        },
        siji:function(){
        return '银角大王'
        }
    }

 {{ nba.yaoming() +'  : ' nba.siji()}}

小程序的冒泡事件

bindxxx 是冒泡事件
catchxxx 是非冒泡事件

.father{
  width: 300rpx;
  height:300rpx;
  background-color: skyblue;
}

.son{
  width: 100rpx;
  height:100rpx;
  background-color: pink;
}

.son2 {
  width: 100rpx;
  height:100rpx;
  background-color: green;
}



父亲
    
      儿子1
    
    
      儿子2
    


 fatherHandle(event){
    console.log("父亲被点击了")
  },
  sonHandle(event){
    console.log("儿子1被点击了")
  },
  son2Handle(event){
    console.log("儿子2被点击了")
  }

你可能感兴趣的:(小程序)