小程序
小游戏
企业微信
微信支付
扫描小程序码分享
希望大神们help一下,我设置了很多button,希望点击每一个button各自出现四张不一样的图片。
19 个回答
加粗
标红
插入代码
插入链接
插入图片
上传视频
touchBtn:function(e){这部分打上去(e)有警告信息
你好,麻烦通过点击下方“反馈信息”按钮,提供出现问题的。
谢谢啦,但是好像还是不行,可能我哪里弄错了
<button class="post" style="margin-top:8%;" bindtap="touchBtn" hover-class="hoverclass" data-id = 1>
大门
</button>
<button class="post" style="margin-top:17%;" bindtap="touchBtn" hover-class="hoverclass" data-id = 2>
教学楼
<view class="img-box">
<image class="image-style" src="{{imgArr[0]}}"></image>
<image class="image-style" src="{{imgArr[1]}}"></image>
<image class="image-style" src="{{imgArr[2]}}"></image>
<image class="image-style" src="{{imgArr[3]}}"></image>
</view>
. var imgArr = [];
touchBtn:function(e){
var data = e.currentTarget.dataset.id;
if(data == 1){//大门
imgArr = [];//存储要展示的图片
}else if(data == 2){//教学楼
}
this.setData({
imgArr: imgArr,
})
data:{
imagesrc:"",
},
btn_a:function(){
imagesrc: "/images/1.png"
btn_b: function () {
imagesrc: "/images/2.png"
<button class="post" style="margin-top:8%;" bindtap="btn_b" hover-class="hoverclass">大门</button>
<button class="post" style="margin-top:17%;" bindtap="btn_c" hover-class="hoverclass">教学楼</button>
<image class="image-style" src="{{imagesrc}}"></image>
能改改嘛?我赋值了几个片段
左边放四个image 用一个view 包起来 右边点击场景切换的时候 控制这个view显示隐藏 给image重新赋值显示新的图片内容 应该就可以了呀
就是这样点击一个按钮左边出现四幅图
你这个出现四张是怎么显示的 有截图吗 是点击一个按钮 预览一个图片吗?预览的话只能预览一个
难点就是我只能弄一张,没办法弄四张
这个的难点在哪里?
正在加载...
关注后,可在微信内接收相应的重要提醒。
请使用微信扫描二维码关注 “微信开放社区” 公众号
touchBtn:function(e){这部分打上去(e)有警告信息
谢谢啦,但是好像还是不行,可能我哪里弄错了
<button class="post" style="margin-top:8%;" bindtap="touchBtn" hover-class="hoverclass" data-id = 1>
大门
</button>
<button class="post" style="margin-top:17%;" bindtap="touchBtn" hover-class="hoverclass" data-id = 2>
教学楼
</button>
<view class="img-box">
<image class="image-style" src="{{imgArr[0]}}"></image>
<image class="image-style" src="{{imgArr[1]}}"></image>
<image class="image-style" src="{{imgArr[2]}}"></image>
<image class="image-style" src="{{imgArr[3]}}"></image>
</view>
. var imgArr = [];
touchBtn:function(e){
var data = e.currentTarget.dataset.id;
if(data == 1){//大门
imgArr = [];//存储要展示的图片
}else if(data == 2){//教学楼
imgArr = [];//存储要展示的图片
}
this.setData({
imgArr: imgArr,
})
}
data:{
imagesrc:"",
},
btn_a:function(){
this.setData({
imagesrc: "/images/1.png"
})
},
btn_b: function () {
this.setData({
imagesrc: "/images/2.png"
})
},
<button class="post" style="margin-top:8%;" bindtap="btn_b" hover-class="hoverclass">大门</button>
<button class="post" style="margin-top:17%;" bindtap="btn_c" hover-class="hoverclass">教学楼</button>
<image class="image-style" src="{{imagesrc}}"></image>
能改改嘛?我赋值了几个片段
左边放四个image 用一个view 包起来 右边点击场景切换的时候 控制这个view显示隐藏 给image重新赋值显示新的图片内容 应该就可以了呀
就是这样点击一个按钮左边出现四幅图
你这个出现四张是怎么显示的 有截图吗 是点击一个按钮 预览一个图片吗?预览的话只能预览一个
难点就是我只能弄一张,没办法弄四张
这个的难点在哪里?