wepy - 與原生有什麼不一樣(事件更改)

 

 

 

 

對於repeat,詳情見官方文檔html

 

 1 <style lang="less">
 2  .userinfo {  3  display: flex;  4     flex-direction: column;  5     align-items: center;  6  }  7   .userinfo-avatar {  8  width: 80rpx;  9  height: 80rpx; 10     border-radius: 50%; 11  } 12   .userinfo-nickname { 13  color: #aaa; 14  } 15  .order { 16  color: #f00; 17  } 18  .btn { 19  width: 150px; 20  height: 30px; 21  color: #fff; 22     line-height: 30px; 23     text-align: center; 24     background-color: aquamarine; 25     border-radius: 10rpx; 26     margin: 5% 0; 27  } 28  .btn:active { 29     opacity: .7; 30  } 31 </style>
32 
33 
34 <template>
35   <view class="container">
36     <!-- 點擊事件 -->
37     <view @tap="click" class='btn'>111{{num}}</view>
38     <!-- 點擊傳值事件 -->
39     <view @tap="clickValue({{num}})" class='btn'>666</view>
40 
41 
42     <!-- 循環組件:repeat -->
43     <repeat for="{{3}}" key="index" index="index" item="item">
44         <view>我要循環{{index}}次!!!</view>
45  {{index}} 46  {{item}} 47     </repeat>
48 
49   </view>
50 </template>
51 
52 <script>
53   /** 54  @tap="click" = bindtap 55  @tap.stop = catchtap 56  @tap.capture = capture-bind:tap 57  @tap.capture.stop = capture-catch:tap 58  @tap="click({{index}}) = bindtap="click" data-index={{index}}" 59      */
60   import wepy from 'wepy'; 61   export default class Index extends wepy.page { 62 
63     data = { 64       num: '我是數字'
65  }; 66 
67     methods = { 68  click() { 69         console.log('點擊我了啊!'); 70  }, 71  clickValue(e) { 72         console.log('我拿data-到值了:', e); 73  } 74  }; 75 
76  onLoad() { 77       console.log('加載事件!'); 78  } 79     
80  } 81 </script>
相關文章
相關標籤/搜索