应该能看明白我的意思吧。。。我刚接触小程序,还请各位海涵
bindsubmit怎么用?为什么我点击两次才能进到if里面formSubmit: function(e) { console.log('图片:', that.data.images) that.data.content = e.detail.value['input-content']; if(Object.keys(that.data.user).length===0){ that.jugdeUserLogin(); } else{ if (that.data.images.lengt > 0){ that.saveDataToServer(); }else if(that.data.content.trim() != ''){ that.saveDataToServer(); console.log("进行内容保存") } else if(that.data.srcVideo.trim()!= ''){ that.saveDataToServer(); }else{ wx.showToast({ icon: 'none', title: '写点东西吧', }) } } }, /** * 保存到发布集合中 */ saveDataToServer: function(event) { console.log("updata添加数据") const db = wx.cloud.database() db.collection('topic').add({ // data 字段表示需新增的 JSON 数据 data: { content: that.data.content, date: new Date(), images: that.data.images, user: that.data.user, isLike:0, srcVideo:that.data.srcVideo, count:0, label:that.data.label, collect:0, }, [图片] 点第一次执行了console.log('图片:', that.data.images) 然后停住了,第二次才又重头进行了一遍
2022-02-08