判断语句怎么使用?
发布于 7 年前 作者 hexia 7159 次浏览 来自 官方Issues
data: {
   or:'false',
   ors:false,
   userInfo: {},
   inputValue:''
 },
 
 //实时写入宿舍号
 bindKeyInput: function (e) {
   this.setData({
     inputValue: e.detail.value
   })
 },
 //表单提交处理
 formSubmit: function (e) {
   console.log('form发生了submit事件,携带数据为:', e.detail.value)   
   var inputValues = this.data.inputValue;
   try {
     wx.setStorageSync('ssh', inputValues)
     //初始化数据库       
     const db = wx.cloud.database()
     //获取记录
     db.collection('dormitory').where({
       hostel: this.data.inputValue
     }).get().then(res => {
       this.setData({
         ors:true
       })
       })
       if(!this.data.ors){
         wx.showToast({
           title: '您输入的宿舍号有误,请重新输入',
           icon: 'none'
         })
       }else{
         wx.redirectTo({
           url: 'detail/details',
         })
       }
   } catch (e) {       }
       
    
 
    
      
    
 },

输入错误的数据时,点击查询,第一次判断进入wx.showToast方法了,但是再点一次就直接进入wx.redirectTo方法跳转了。怎么回事?数据没有改动,appdata中ors的仍然是false。

5 回复

代码没看见有语法错误的问题,所以我跟楼上 有脾气的酸奶 想的一样

自己都已经设置为true了

debugger 是个好东西,建议用起来

你先这样 然后再这样 最后这样 就行了

this在外部定义一下 let that = this;this.setData({})

回到顶部