微信小程序入门中scroll-view那块颜色不显示问题
2019-03-11 16:25
162 查看
在学习微信小程序开发中,到了scroll-view这一块的时候,为了给我们更好的讲解。给我们提供了测试代码。
.xwml文件
<view class="section"> <view class="section__title">vertical scroll</view> <scroll-view scroll-y 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 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>
.js文件
const order = ['red', 'yellow', 'blue', 'green', 'red'] Page({ data: { toView: 'red', scrollTop: 100 }, upper(e) { console.log(e) }, lower(e) { console.log(e) }, scroll(e) { console.log(e) }, tap(e) { for (let i = 0; i < order.length; ++i) { if (order[i] === this.data.toView) { this.setData({ toView: order[i + 1] }) break } } }, tapMove(e) { this.setData({ scrollTop: this.data.scrollTop + 10 }) } })
想要我们显示的效果如下
但是复制代码以后没有显示想要的颜色
需要在wxss里面设置对应得颜色
.bc_green { background-color: green; } .bc_red { background-color: red; } .bc_yellow { background-color: yellow; } .bc_blue { background-color: blue; }
相关文章推荐
- 微信小程序scroll-view bindscrolltoupper & bindscrolltolower不响应的问题
- 微信小程序(三个小点)颜色显示问题
- 解决微信小程序组件scroll-view中bindscrolltolower事件触发不了的问题
- 【微信小程序】解决 竖向<scroll-view>组件 “竖向滚动页面出现遮挡”问题
- 完美解决微信小程序scroll-view高度自适应机型宽度的问题
- 微信小程序 解决 view 文字 过多 溢出的问题,超过行数后隐藏显示省略号
- 详解微信小程序之scroll-view的flex布局问题
- 关于微信小程序scroll-view横向滑动问题
- 微信小程序scroll-view在ios上滑动卡顿问题
- 微信小程序存在scroll-view为外层时,制作模拟框(全页面变成透明的黑色,出现一个模拟框)的兼容性问题
- 【微信小程序】View组件与Flexbox弹性盒模型 字体颜色摆放显示案例,
- 微信小程序scroll-view高设置100%在苹果6p下的兼容性问题
- 微信小程序之scroll-view横向滚动不能显示
- UITableView 一直显示滚动条(ScrollBar Indicators)、滚动条Width(宽度)、滚动条Color(颜色)
- 关于微信小程序下拉刷新组件加载图片(三个小点)不显示的问题
- PullToRefreshScrollView 嵌套 ViewPager 冲突导致界面不显示的问题
- 微信小程序开发(十四)scroll-view实现下拉刷新上拉加载更多
- 微信小程序如何实现通过点击view改变背景颜色
- TextView显示颜色高亮的问题
- 【微信小程序常见问题】使用picker组件显示年份解决方案