微信小程式實現web端錨點功能
1.wxml佈局樣式
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
< view bindtap='clickScroll' data-id="{{item}}">{{item}}</ view >
|
2.wscc樣式
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
|
3.js
1 2 3 4 5 6 7 8 9 10 11 12 |
Page({ data: { list: ["list0", "list1", "list2", "list3", "list4", "list5", "list11", "list12", "list13", "list14", "list15", "list25", "list26", "list27", "list28", "list29", "list30"], toView: '' }, clickScroll:function(e){ var id = e.currentTarget.dataset.id this.setData({ toView:id }) console.log(e.currentTarget.dataset); }, }) |