微信小程序,给一个button绑定自己定义的函数

在wxml中声明一个

<button class='btn1' bindtap="goToPage1">测试Button </button>

 

在wxss中弄个好看点的皮肤

.btn1 {

  width:80%;

  margin-top:130rpx;

  background-color: rgb(106, 0, 95);

  color: white;

  border-radius: 98rpx;

  display: flex;

  flex-direction: row;

  align-items: center;

  justify-content: center;

}

 

然后在js中创建这个函数:goToPage1

goToPage1:function(){

    console.log("Hello world")

}

posted @ 2020-12-03 21:21  bH1pJ  阅读(103)  评论(0编辑  收藏  举报