- 为什么固定表头后上拉加载会失效?
表头没固定之前一切正常,固定之后上拉顶多只能触发一次,怎么破。。 [图片] [图片] <view class="tableHeader"> <view class="searchbar"> <navigator url='/pages/search_drug/search_drug' class='search-navigator'></navigator> </view> <text class="title">药品信息表</text> <view class="divLine"></view> <view class="tr thColor"> <view class="th">药品号</view> <view class="th">药品名</view> <view class="th">价格</view> <view class="th">库存</view> </view> </view> <scroll-view scroll-x="true" scroll-y="true" style='height:{{tbodyHeight}}px'> //加了表头固定只能触发一次上拉加载 <block wx:for="{{result}}" wx:key="id"> <view class="tr" wx:if="{{index%2==0}}"> <view class="td">{{item.id}}</view> <view class="td">{{item.name}}</view> <view class="td">{{item.price}}</view> <view class="td">{{item.count}}</view> </view> </block> </scroll-view> <loadingmore hasmore="{{bool}}"></loadingmore>
2020-04-05 - 在固定表头的同时如何让整个表格可以同步左右滑动?
必须要固定表头,但表格过宽要左右滑动,我现在做的这个表头和表格是分开滑动的,体验极差,怎么让它们同步滑动啊 [图片][图片] [图片] wxml: <view class="tableHeader"> <view class="searchbar"> <navigator url='/pages/search_worker/search_worker' class='search-navigator'></navigator> </view> <text class="title">职员信息表</text> <view class="divLine"></view> <scroll-view scroll-x="true"> <view class="tr thColor"> <view class="th">职工号</view> <view class="th">性别</view> <view class="th">姓名</view> <view class="th">年龄</view> <view class="th">科室号</view> <view class="th">联系电话</view> </view> </scroll-view> </view> <scroll-view scroll-x="true" scroll-y="true" style='height:{{tbodyHeight}}px'> <block wx:for="{{result}}" wx:key="id" > <view class="tr"> <view class="td">{{item.id}}</view> <view class="td">{{item.sex}}</view> <view class="td">{{item.name}}</view> <view class="td">{{item.age}}</view> <view class="td">{{item.officeid}}</view> <view class="td">{{item.phonenumber}}</view> </view> </block> </scroll-view> <loadingmore hasmore="{{bool}}"></loadingmore> js: onShow: function () { var that = this; that.getInfo(1); setTimeout(function (){ wx.getSystemInfo({ success: (res) => { let windowHeight = res.windowHeight; console.log(windowHeight); const query = wx.createSelectorQuery().in(that) query.selectAll('.tableHeader').boundingClientRect((rects) => { let rect = rects[0]; console.log(rect); let height = windowHeight - rect.height; that.setData({ tbodyHeight: height.toFixed(0), }) }).exec(); } }); },500) }
2020-04-05 - 小程序表单按钮要按两次才能提交怎么解决?
写了个登录界面,电脑上没问题,真机调试的时候必须要按两次提交按钮才能把信息提交上去,consol.log一看提交的信息,发现第一次根本就没提交上去,我猜第一次大概是因为要隐藏键盘,第二次才是真正的提交,用户体验极差。。怎么解决啊 [图片][图片] 代码片段如下: wxml: <form bindsubmit='onSubmit'> <view class="section-container"> <image class='image' src='/images/others/account.png'></image> <input class="common-input" name="phoneNumber" maxlength='11' type="text" placeholder="请输入账号/手机号"></input> </view> <view class="section-container"> <image class='image' src='/images/others/password.png'></image> <input class="common-input" name="password" type="password" placeholder="请输入密码"></input> </view> <view class="btn-area"> <button class="btn" form-type='submit' style="background:#3775F6; color:white" bindtap="login">登录</button> </view> </form> js: Page({ data: { }, onSubmit:function(event){ var value = event.detail.value; var phoneNumber = value.phoneNumber; var password = value.password; this.setData({ phoneNumber: phoneNumber, password: password }) }, login:function(event) { wx.clearStorageSync(); var that=this; var phoneNumber = that.data.phoneNumber; var password = that.data.password; var checkPhone = /^1(3|4|5|7|8)\d{9}$/; console.log(phoneNumber); if (!(checkPhone.test(phoneNumber))) { wx.showToast({ title: '手机号错误!', duration: 2000, image: '/images/others/wrong.png' }) return false; } } })
2020-04-04 - 小程序下载的文档中文为什么乱码了?
从一个接口下载了csv文件,中文全部乱码了,怎么恢复正常啊,我在header里已经设置UTF8编码了 wx.downloadFile({ url: url, method: 'GET', header: { "cookie": cookie, "Content-Type": 'charset=UTF-8' }, success: function (res) { var tempFilePath = res.tempFilePath; console.log(res); wx.saveFile({ tempFilePath: tempFilePath, success: function (res) { var savedFilePath = res.savedFilePath; }, }) }, }) [图片]
2020-04-03 - 真机调试要点两次才能登录是为什么?
电脑上一切正常,一次登录就能进,用iPhone7真机调试时必须点两次登录才能进,而且第一次报错,第二次正常,什么情况。。我的密码先是md5加密,和这个有关系吗 [图片] [图片] js: Page({ data: { }, onSubmit:function(event){ var value = event.detail.value; var phoneNumber = value.phoneNumber; var password = value.password; this.setData({ phoneNumber: phoneNumber, password: password }) }, login(event) { var that=this; var phoneNumber = that.data.phoneNumber; var password = that.data.password; var utilMd5 = require('../../utils/md5.js'); var password = utilMd5.hexMD5(password); wx.showLoading({ title: '登录中...' }); wx.request({ url: 'xxxxxxx', method: 'POST', header: { "Content-Type": "application/x-www-form-urlencoded" }, data: { phoneNumber: phoneNumber, password: password }, success:function(res) { wx.setStorageSync('sessionid', res.cookies[0]), console.log(res); wx.switchTab({ url: "/pages/download/download" }); }, fail:function(){ console.log('账号或密码错误') } }) } }) wxml: <view class="login-container"> <form bindsubmit='onSubmit'> <view class="section-container"> <image class='image' src='https://s1.ax1x.com/2020/04/01/G1DZWR.png'></image> <input class="common-input" name="phoneNumber" placeholder="请输入账号/手机号"></input> </view> <view class="section-container"> <image class='image' src='https://s1.ax1x.com/2020/04/01/G1B5RI.png'></image> <input class="common-input" name="password" password placeholder="请输入密码"></input> </view> <view class="btn-area"> <button class="btn" form-type='submit' style="background:#3775F6; color:white" bindtap="login">登录</button> </view> </form> </view>
2020-04-03 - 小程序怎么下载非图片文件到本地?
我要下的是个csv文件,代码运行后报错了,下载的文件要存在哪里呢?下载完之后在哪找到文件呢? [图片] [图片]
2020-04-03