解决方案:javascript
解决方案:html
capture-catch:touchmove="myCatchTouch"
myCatchTouch: function() {
console.log('stop user scroll it!');
return;
},
复制代码
style={
position: fixed;
top: 0;
bottom: 0;
right: 0;
left: 0;
}
复制代码
小程序文档java
解决方案: 添加fixed属性android
<textarea placeholder="备注留言"
maxlength='50'
fixed
name="textarea"
placeholder-style='font-size: 28rpx;color: #C7C7CD;text-align: justify;line-height: 42rpx;border-radius:10rpx !important'
bindinput='setRemark'
cursor-spacing='100'/>
复制代码
Do not have hidden handler in current page: pages/huodongye/huodongye. Please make sure that hidden handler has been defined in pages/huodongye/huodongye, or pages/huodongye/huodongye has been added into app.json
强制border:none
无效 实现方案:ios
button::after {
border: none
}
复制代码
在button 或者input框等可点击的元素外面嵌套多层form以及button,屡次触发submit
事件便可git
项目中须要根据返回的数字显示汉字,须要在wxml中使用方法。web
官方解决方案:WXSajax
WXS(WeiXin Script)是小程序的一套脚本语言,结合 WXML,能够构建出页面的结构。json
注意axios
示例:
<!--wxml-->
<!-- 下面的 getMax 函数,接受一个数组,且返回数组中最大的元素的值 -->
<wxs module="m1">
var getMax = function(array) {
var max = undefined;
for (var i = 0; i <array.length; ++i) {
max = max === undefined ? array[i] : (max >= array[i] ?
max : array[i]);
}
return max;
}
module.exports.getMax = getMax;
</wxs>
<!-- 调用 wxs 里面的 getMax 函数,参数为 page.js 里面的 array -->
<view>{{m1.getMax(array)}}</view>
复制代码
复现: 登陆拦截失败后应用的redirectTo
,用户登录成功后 应用navigateBack
没有返回上一级;
解决方法: navigateBack
应该与navigateTo
配对使用; so, 把redirectTo
改成navigateTo
,再应用navigateBack({delta: 1})
就成功了。
教训:老娘有史以来写的最严重的线上bug.哎,测试时觉得是后端bug,测试方案没覆盖全。小程序接口使用前仍是得快速念一遍啊。
e.target
涉及事件委托。
问题描述:init函数须要app.js执行后的全局变量
onLoad: function () {
console.log('onLoad')
if (app.globalData.boliSid) {
if (!app.globalData.isBoundMobile) {
wx.redirectTo({
url: "/pages/binding/binding",
})
return false
}
this.setData({
isBinding: true
})
this.init()
} else {
app.getAuthKey().then(res => {
if (res.data.code == 200) {
app.globalData.boliSid = res.data.data.boli_sid
app.globalData.isBoundMobile = res.data.data.is_bound_mobile
}
if (!app.globalData.isBoundMobile) {
wx.redirectTo({
url: "/pages/binding/binding",
})
return false
}
this.setData({
isBinding: true
})
// 这里是ajax请求啊
this.init()
})
}
console.log(app.globalData,'global')
}
复制代码
init函数:
init: function(e) {
let that = this
console.log(e,'e')
console.log(app.globalData,'init global')
let configData = {
boli_sid: app.globalData.boliSid,
map_lat: app.globalData.latitude,
map_lng: app.globalData.longitude,
page: 1,
size: 10,
type: 0
}
console.log(configData,'configData')
let config = {
data: configData,
url: 'https://test.anjuy.cn/@wxapp/logistic/index',
isLoading: true
}
axios(config).then(res => {
// console.log(res.data,'data')
if (res.data.code == 200) {
that.setData({
initData: res.data.data
})
console.log( this.data.initData,'res')
wx.showToast({
title: '成功',
icon: 'success',
duration: 2000
})
}
}).catch(e => {
wx.showModal({
title: '提示',
content: '这是一个模态弹窗',
success(res) {
if (res.confirm) {
console.log('用户点击肯定')
} else if (res.cancel) {
console.log('用户点击取消')
}
}
})
})
},
复制代码
正常执行; 必须确保app.js全局变量正常才能执行init() 注意同步异步事件
onPullDownRefresh触发条件??
onPullDownRefresh: function () {
console.log(this.data.page,'page')
this.init()
},
onReachBottom: function () {
this.init()
},
复制代码
解决方案: 须要json文件进行配置
{
"enablePullDownRefresh": true,
"onReachBottomDistance": 50,
}
复制代码
问题描述:请求成功200后添加代码,toast组件一直未执行
axios(config).then( res => {
if(+res.data.code == 200){
wx.showToast({
title: '取件成功',
icon: 'success',
duration: 1500
})
that.search = that.selectComponent('#mySearch');
that.search.delValue();
that.init()
}
}, e => {
console.log(e)
})
复制代码
解决方案:
setTimeout(() => {
wx.showToast({
title: '取件成功',
icon: 'success',
duration: 1500
})
},300)
复制代码
当设置的字体过大,如80rpx,输入框会发生切割,文字展现不全; 重设input高度,覆盖默认的height和min-height
input {
font-size: 80rpx;
line-height: 90rpx;
height: 90rpx;
min-height: 90rpx;
}
复制代码
<scroll-view class="comments" scroll-x="true">
<view style="display:flex;align-items:top;">
<view class="item">1</view>
<view class="item">2</view>
<view class="item">3</view>
</view>
</scroll-view>
复制代码
white-space: nowrap;
<view style="display:flex;align-items:top;">
为了解决内部滚动元素底部对齐问题 3) 内部元素item
必须加上display: inline-block;
to be solved