uniapp遇到的问题
1 uniapp 回调函数修改data里面的值在回调函数后面加 .bind(this)uni.showModal({content:'是否选择'+this.date+'出发',success:function(res){if(res.confirm){this.isShow = false}else if(res.cancel){this.isShow = falsethis.date = '
·
1 uniapp 回调函数修改data里面的值
在回调函数后面加 .bind(this)
uni.showModal({
content:'是否选择'+this.date+'出发',
success:function(res){
if(res.confirm){
this.isShow = false
}else if(res.cancel){
this.isShow = false
this.date = '请选择日期'
}
}.bind(this)
})
2 uniapp页面传参
1.定义一个事件,
2.事件后跟上要传的参数
@click="onClick(index,date,week,item.time,item.start,item.end,item.time1)"
3.利用内置api传值
onClick(index,date,week,time,start,end,time1){
console.log(index)
uni.navigateTo({
url:'../txdd/txdd?date='+date+'&week='+week+'&time='+time+'&start='+start+'&end='+end+'&time1='+time1,
})
},
4.在新页面接收
onLoad(options){
console.log(options.time)
this.date = options.date
this.week =options.week
this.time = options.time
this.start = options.start
this.end = options.end
this.time1 = options.time1
}
3 uniapp小程序v-for传值为undefined
描述:
在uniapp中用v-for绑定了值,h5页面正常传参,而小程序里面前面没有用v-for循环的就传成功了,其他的用v-for传的值则为空
<view class="box" v-for="(item,index) in detailList" :key="item.index" @click="onClick(index,date,week,item.time,item.start,item.end,item.time1)">
解决方法:
找到v-for循环里的key将其值绑定为index
:key="index"
更多推荐
已为社区贡献5条内容
所有评论(0)