2 回复
wxml文件
< image src = "{{big_url}}" ></ image > < view wx:for = "{{small}}" wx:key = "{{index}}" > < image src = "{{item.url}}" bindtap = "click" data-url = "{{item.url}}" style = "width:100px;height:100px;float:left;margin-right:10px" ></ image > </ view > |
js文件
Page({ data: { big_url: '../../images/1.jpg' , small:[ { url: '../../images/1.jpg' }, { url: '../../images/2.jpg' }, { url: '../../images/3.jpg' }, ] }, onLoad: function (e){ console.log( this .data.big_url) }, click: function (e){ var that= this var new_url = e.currentTarget.dataset.url that.setData({ big_url:new_url }) }, }) |