多应用+插件架构,代码干净,二开方便,首家独创一键云编译技术,文档视频完善,免费商用码云13.8K 广告
[TOC] ## wxml ``` <form bindsubmit="onConfirm"> <button class="btn" plain="{{true}}" formType="submit">确定</button> //确定按钮 plain="{{true}}"背景色透明 <input type="text" placeholder="请输入短评最多12个字" value="{{value}}" bind:confirm="onConfirm" confirm-type="search" name="search" /> //name值 是传给button的值 </form> ``` ## js ``` //http请求 onLoad: function (options) { const id = options.id; const detail = bookModel.getBookDetail(id); const comments = bookModel.getBookComment(id); const likeStatus = bookModel.getBookLike(id); Promise.all([detail,comments,likeStatus]).then(res=>{ let [detail,comments,likeStatus] = res; this.setData({ detail, comments:comments.comments, likeStatus }) }) }, onConfirm(event){ //让按钮的值和input直接enter的值相同 let value = event.detail.value; if(typeof value != "string"){ value = event.detail.value.search; } //当没有输入内容时,不能添加 if(value != ""){ console.log(value) //当添加时出现 +1的弹出框 var add = true wx.showToast({ title: add ? "+1" : "", icon: 'none' }); //从前添加在评论前面加入新的评论 this.data.comments.unshift({ content: value, nums:1 }) //将新的评论集重新命名为comment this.setData({ comments:this.data.comments, isShow:false }) } } ``` ## wechat2.0问题残留 点击评论热门时 post 成功的 插槽 点赞数 不能及时更新