收藏
回答

scroll-view 的scroll-into-view失效

框架类型 问题类型 API/组件名称 终端类型 操作系统 微信版本 基础库版本
小程序 Bug scroll-view 客户端 Android 6.6.6 1.02

想实现点击左侧 级别,右侧跟随滚动,但是试了几次均未实现,下面附上demo

wxml

<scroll-view scroll-y="true" scroll-into-view="{{toView}}"  style="height: 6000px;">  

<view id='{{item.wordindex}}' class="brand" wx:for="{{brandList}}" >  

<view class="line"></view>  

<view class="wordindex">{{item.wordindex}}</view>  

<view class="line"></view>  

<view class="brand_block">  

<view class="color_view" wx:for="{{item.brand}}" bindtap="click">  

<image src="{{item.brandimg}}"></image>  

</view>  

</view>  

</view>  

</scroll-view>  

<view class="index">  

<text wx:for="{{wordindex}}" bindtap="choiceWordindex" data-wordindex="{{item.wordindex}}">  

{{item.wordindex}}

</text>  

</view>


wxss

/* pages/order/car/add_car/car_brand/car_brand.wxss */  

scroll-view {

height: 600px;

float: left;

width: 94%;

}

.wordindex {

line-height: 50rpx;

background: #f7f7f7;

font-size: 14px;

color: #929292;

padding-left: 28rpx;

}

.color_view {

text-align: center;

display: inline-flex;

flex-direction: column;

}

.brand_block {

margin-top: 28rpx;

margin-left: 28rpx;

}

image {

width: 140rpx;

height: 140rpx;

margin-right: 24rpx;

margin-bottom: 24rpx;

border-style: solid;

border-width: 1rpx;

border-color: #ededed;

}

.index {

float: right;

position: fixed;

right: 0;

margin-top: 20%;

margin-right: 10rpx;

color: #e0004a;

font-size: 11px;

}

.index text {

display: flex;

line-height: 18rpx;

}


js


var app = getApp()

Page({

data: {

"brandList": [],

"wordindex": [],

"toView": 'a',


},

onLoad: function (options) {

var that = this;

that.setData({

brandList: [{ wordindex: 'a' }, { wordindex: 'b' }, { wordindex: 'c' }, { wordindex: 'd' }, { wordindex: 'e' }, { wordindex: 'f' }, { wordindex: 'g' }, { wordindex: 'h' }, { wordindex: 'i' }, { wordindex: 'j' }, { wordindex: 'k' }, { wordindex: 'l' }, { wordindex: 'o' }, { wordindex: 'p' }, { wordindex: 'q' }, { wordindex: 'r' }, { wordindex: 's' }, { wordindex: 't' }, { wordindex: 'w' }],

wordindex: [{ wordindex: 'a' }, { wordindex: 'b' }, { wordindex: 'c' }, { wordindex: 'd' }, { wordindex: 'e' }, { wordindex: 'f' }, { wordindex: 'g' }, { wordindex: 'h' }, { wordindex: 'i' }, { wordindex: 'j' }, { wordindex: 'k' }, { wordindex: 'l' }, { wordindex: 'o' }, { wordindex: 'p' }, { wordindex: 'q' }, { wordindex: 'r' }, { wordindex: 's' }, { wordindex: 't' }, { wordindex: 'w' }]})


},

onReady: function () {

// 页面渲染完成  

},

onShow: function () {

// 页面显示  

},

onHide: function () {

// 页面隐藏  

},

onUnload: function () {

// 页面关闭  

},

click: function () {

wx.navigateTo({

url: '/pages/order/car/add_car/car_model/car_model',

})

},

choiceWordindex: function (event) {

let wordindex = event.currentTarget.dataset.wordindex;

if (wordindex == '#') {

this.setData({

toView: '常用品牌',

})

} else {

this.setData({

toView: wordindex,

})

}


console.log(this.data.toView);

}

})


回答关注问题邀请回答
收藏

2 个回答

  • 长勿相忘
    长勿相忘
    2018-04-24

    wechatide://minicode/5BljGUmd6tYg   您好,您看下这个可以吗

    2018-04-24
    有用
    回复
  • 疯狂的小辣椒
    疯狂的小辣椒
    2018-04-24

    麻烦给个相关的代码片段(https://developers.weixin.qq.com/miniprogram/dev/devtools/minicode.html),我们定位下问题

    2018-04-24
    有用
    回复
登录 后发表内容