<scroll-view scroll-y="true" scroll-into-view="{{toView}}">
<view class="brand" wx:for="{{brandList}}">
<view class="line"></view>
<view id="{{item.wordindex}}" 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>
// pages/order/car/add_car/car_brand/car_brand.js
var app = getApp()
Page({
data: {
"brandList": [],
"wordindex": [],
"toView": '#',
},
onLoad: function (options) {
var that = this;
// 页面初始化 options为页面跳转所带来的参数
app.func.req('getCarBrand?cx=1', function (res) {
if (res.data.result == 'false') {
console.log('false');
that.wetoast.toast({
title: res.data.msg,
duration: 2000
})
} else {
that.setData({
brandList: res.data.brandList,
wordindex: res.data.brandList,
});
var cData = that.data.brandList;
cData[0].wordindex = "#";//先修改json值
that.setData({ //再set值
wordindex: cData
})
}
}, function (res) {
});
},
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);
}
})