本篇文章主要介绍了微信小程序 scroll-view实现锚点滑动的示例,小编觉得挺不错的,现在分享给大家,也给大家做个参考。一起跟随小编过来看看吧前言最近开始做小程序,通读一遍文档再上手并不算难,但不得不说小程序里还是有一些坑。这里说一下如何实现页面锚点跳转,一个城市列表的效果示意图如下:因为在微信小程序的环境中不能想在浏览器里设置标签,或者操作dom滚动,传统做法就行不通了,一切都得按小程序的文档来。一开始我们...
这篇文章主要为大家详细介绍了微信小程序scroll-view组件实现滚动动画,具有一定的参考价值,感兴趣的小伙伴们可以参考一下本文实例为大家分享了scroll-view组件实现索引列表滚动动画效果,供大家参考,具体内容如下实现原理利用scroll-view的scroll-into-view属性进行定位;利用scroll-view的scroll-with-animation属性实现滚动动画过度。WXML<view class="right-nav"><view bindtap="getCurrentCode" class="{{chooseIndex == in...
一、实践踩坑项目使用mpvue开发
1.使用flex布局
// html大概长这样<div class="worth-wraper"><scroll-view scroll-x="true" scroll-left="0"><div class="worth-list"><div class="worth-item-img"><img src="/static/images/index/brand1.png" alt=""></div><div class="worth-item-img"><img src="/static/images/index/brand2.png" alt=""></div><div class="worth-item-img"><img src="/static/images/index/brand3.png" alt=...
一、实践踩坑
项目使用mpvue开发
1. scroll-view默认是不滚动的。。所以要先设置scroll-x="true"或者scroll-y="true"2. 在scroll-view里面添加定宽元素,超过scroll-view宽度(设置了100%,即屏幕宽度)后,它竟然换行了。所以要scroll-view的样式要这样设置:scroll-view {width: 100%;white-space: nowrap; // 不让它换行}3. 然后在定宽元素里边添加子容器:
// html大概长这样
<scroll-view scroll-x="true"><div class="tab-ite...
关于微信小程序的scroll-view组件,第一次写的时候是直接在scroll-view中用了一层容器包裹子元素,然后用了flex布局,并且是用了组件来实现的横向滚动,后面有提出改进,但是不记录下,就发现过了几天,就有点懵了
1.效果图2.在scroll-view里加一层容器,使用flex布局实现
这里用flex布局实现的话,就要用组件的形式
wxss文件
.scrollView{padding: 0 20rpx;white-space: nowrap;box-sizing: border-box;
}
.item{display: inline-...
具体代码如下所示:
// 1.scroll-y="true" Y轴滚动
// 2.应该是设置了高才能行
// 3.使用scroll-top属性实现滚动到底部,scroll-top不要带单位
<scroll-view scroll-y="true" style="height:{{height-50}}px;" scroll-top="{{scrollTop}}"><block wx:for="{{recordList}}" wx:key="item.id"><view><text>{{item.text}}</text></view</block>
</scroll-view>Page({data: {// 列表recordList:,height: ,scrollTop: 0},onLoad: funct...
表现
设置了scroll-top的scroll-view组件,在组件所在vue实例data发生改变时会自动回弹到最上方
解决方案
打开 node_modules/mpvue/index.js, 在任意位置添加以下两个方法
function calcDiff(holder, key, newObj, oldObj) {if (newObj === oldObj || newObj === undefined) {return}if (newObj == null || oldObj == null || typeof newObj !== typeof oldObj) {holder[key] = newObj} else if (Array.isArray(newObj) && Array.i...
前言:这章我们使用小程序的 scroll-view组件 实现横向滚动和竖向滚动。
GitHub: https://github.com/Ewall1106/miniProgramDemo
1、竖向滚动
首先从简单的来,竖向滚动很简单,只用记住两点即可:
首先得设置 scroll-y 属性; 其次,一定要给 scroll-view 设置一个 height 高度;
<scroll-view scroll-y style="height: 200px;"><view class="green" style="width: 100%; height: 200px; background: green;"></view><view class...
1、布局及样式等(1)xml布局
<view class="container"><scroll-view scroll-x="true"><view class="item-content" wx:for="{{list}}" wx:for-item="item"><view class="title">{{item.title}}</view><view class="content">{{item.content}}</view></view></scroll-view>
</view>
(2)wxss
scroll-view {width: 80%;white-space: nowrap;
}.item-content {width: 40%;display: inline-block;border: 1rpx solid gray;text-align:...
scroll-view滚动穿透,阻止滚动页面弹窗阻止滚动是一种常见的问题,这里简单介绍小程序scroll-view的一种解决方式
常用阻止滚动方式在不使用scroll-view的弹窗中, 为position为absolute或fixed的元素设置catchtouchmove空事件就可以阻止弹窗下的页面因事件穿透滚动
<view catchtouchmove="doNothing"></view>也可直接写catchtouchmove,相当于绑定了事件名为true的事件
问题场景在小程序中,在absolute或fixed的类弹窗布局中。要显...
本文实例为大家分享了微信小程序scroll-view实现字幕滚动的具体代码,供大家参考,具体内容如下
需求:
实现框内的文字自下而上的自动循环滚动。
解决方案:
demo:字幕滚动
通过控制滑动条来完成字幕滚动,通过setinterval完成字幕循环滚动。
wxml:
<scroll-view class="container" scroll-y="true" bindscroll="scroll" scroll-top="{{scrollTop}}"><view class=list><view class=blank></view><view><text class="txt-light">09:...
本文实例为大家分享了微信小程序横向滑动滚动条的具体代码,供大家参考,具体内容如下
效果图实现代码
index.wxml
<scroll-view scroll-x="true" class="scroll-view-x" style="padding-top:10rpx" scroll-with-animation="true" wx:if="{{tlist[currentTab].secondList}}" scroll-left=0 bindscroll="getleft"><!--内容区域--><view><view class="navigator_second" wx:for="{{tlist[currentTab].secondList}}" wx:for-item="chi...
本文实例为大家分享了scroll-view组件实现索引列表滚动动画效果,供大家参考,具体内容如下效果图实现原理
利用scroll-view的scroll-into-view属性进行定位;
利用scroll-view的scroll-with-animation属性实现滚动动画过度。WXML
<view class="right-nav"><view bindtap="getCurrentCode" class="{{chooseIndex == index ? .city-list-active : }}" wx:for="{{cityList}}" style="height:{{codeHeight}}px" data-code="{{item.code...
前言
最近开始做小程序,通读一遍文档再上手并不算难,但不得不说小程序里还是有一些坑。这里说一下如何实现页面锚点跳转,一个城市列表的效果示意图如下:因为在微信小程序的环境中不能想在浏览器里设置标签,或者操作dom滚动,传统做法就行不通了,一切都得按小程序的文档来。一开始我们的做法是使用boundingClientRect()方法获取每个锚点的坐标,然后再用wx.pageScrollTo()方法滑动过去。结果发现效果不是很好,因为boundingCli...
wxml<scroll-view class="recommend_scroll_x_box" scroll-x="true"><view class="recommend_hot_box" wx:for="{{hotList}}"><image src="{{item.pic}}" class="recommend_hot_image"></image></view></scroll-view>wxss
.recommend_scroll_x_box {height: 245rpx;white-space: nowrap;display: flex;
}::-webkit-scrollbar {width: 0;height: 0;color: transparent;
}.recommend_hot_box {width: 230rpx;height: 245rpx;margin-ri...