WeChat applet tutorial wxapp view container scroll-view

高洛峰
Release: 2017-02-14 14:43:59
Original
1655 people have browsed it

This article mainly introduces the relevant information of the wxapp view container scroll-view in the WeChat applet tutorial. Friends in need can refer to


Related articles:

  1. WeChat Mini Program Tutorial wxapp view container swiper

  2. WeChat Mini Program Tutorial wxapp view container scroll-view

  3. WeChat applet tutorial wxapp view container view

scroll-view

Scrollable view area.


##scroll-topNumberSet the vertical scroll bar positionscroll-leftNumberSet the horizontal scroll bar positionscroll-into-viewStringThe value should be If the id of a child element is specified, scroll to the element, and the top of the element is aligned with the top of the scroll area bindscrolltoupperEventHandleScroll Go to the top/left, the scrolltoupper event will be triggeredbindscrolltolowerEventHandleScroll to the bottom/right, the scrolltolower will be triggered EventbindscrollEventHandleTriggered when scrolling, event.detail = {scrollLeft, scrollTop, scrollHeight, scrollWidth, deltaX, deltaY}
Attribute name Type Default value Description
scroll-x Boolean false Allow horizontal scrolling
scroll-y Boolean false Allow vertical scrolling
upper-threshold Number 50 How far away from the top/left (unit px) is to trigger the scrolltoupper event
lower-threshold Number 50 How far away from the bottom/right (unit px) is to trigger the scrolltolower event
When using vertical scrolling, you need to give a fixed height and set the height through WXSS.


Sample code:

<view class="section">
 <view class="section__title">vertical scroll</view>
 <scroll-view scroll-y="true" style="height: 200px;" bindscrolltoupper="upper" bindscrolltolower="lower" bindscroll="scroll" scroll-into-view="{{toView}}" scroll-top="{{scrollTop}}">
 <view id="green" class="scroll-view-item bc_green"></view>
 <view id="red" class="scroll-view-item bc_red"></view>
 <view id="yellow" class="scroll-view-item bc_yellow"></view>
 <view id="blue" class="scroll-view-item bc_blue"></view>
 </scroll-view>

 <view class="btn-area">
 <button size="mini" bindtap="tap">click me to scroll into view </button>
 <button size="mini" bindtap="tapMove">click me to scroll</button>
 </view>
</view>
<view class="section section_gap">
 <view class="section__title">horizontal scroll</view>
 <scroll-view class="scroll-view_H" scroll-x="true" style="width: 100%">
 <view id="green" class="scroll-view-item_H bc_green"></view>
 <view id="red" class="scroll-view-item_H bc_red"></view>
 <view id="yellow" class="scroll-view-item_H bc_yellow"></view>
 <view id="blue" class="scroll-view-item_H bc_blue"></view>
 </scroll-view>
</view>
Copy after login

var order = [&#39;red&#39;, &#39;yellow&#39;, &#39;blue&#39;, &#39;green&#39;, &#39;red&#39;]
Page({
 data: {
 toView: &#39;red&#39;,
 scrollTop: 100
 },
 upper: function(e) {
 console.log(e)
 },
 lower: function(e) {
 console.log(e)
 },
 scroll: function(e) {
 console.log(e)
 },
 tap: function(e) {
 for (var i = 0; i < order.length; ++i) {
  if (order[i] === this.data.toView) {
  this.setData({
   toView: order[i + 1]
  })
  break
  }
 }
 },
 tapMove: function(e) {
 this.setData({
  scrollTop: this.data.scrollTop + 10
 })
 }
})
scroll-view
Copy after login

微信小程序 教程之wxapp视图容器 scroll-view

Thank you for reading, I hope it can help you, thank you for your support of this site!

For more WeChat applet tutorial wxapp view container scroll-view related articles, please pay attention to the PHP Chinese website!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!