获取位置调用地图--小程序端无响应
uni.chooseLocation方法打开地图选位,在H5,app都正确,但小程序需要授权,所以要使用uni为小程序专设的uni.getSetting和uni.authorize方法解决授权问题。另外记得在manifest.json文件小程序设置->位置接口填写下描述
//#ifdef MP-WEIXIN 当为小程序是才执行,app、h5不执行
get_location() {
const that = this
uni.showLoading({
title: '加载中',
mask: true
});
//#ifdef MP-WEIXIN
uni.getSetting({
success(res) {
if (!res.authSetting['scope.userLocation']) {
uni.authorize({
scope: 'scope.userLocation',
success() {
that.chooseLocation()
return;
}
})
}else{
that.chooseLocation()
return;
}
}
})
//#endif
that.chooseLocation()
},
chooseLocation(){
uni.chooseLocation({
success: function(res) {
that.address = res.name
that.form.position = res
}
});
},
rich-text 图片超出的问题
JS上过滤一下内容即可
this.$api.http.get('single_article/'+this.id).then((res)=>{
this.article = res
this.article.content=this.min_img(res.content)
});
min_img(content){
let s=content.replace(/\<img/gi, '<img class="rich-img" style="max-width:100%;height:auto"')
return s;
}
<style lang="less">
.rich-img {
width: 100%;
height: auto ;
}
</style>
动态绑定样式--小程序不支持
H5没问题,小程序会报错:“:class 不支持 fun() 语法”
<view class='swip-box' :class="fun(index)" >xxx</view>
是因为不能有括号,没法用函数,改用计算属性即可。
H5和小程序的请求正常,APP下请求失败
APP请求报错:request:fail abort
网上说是ssl、证书等问题,但并未解决。
token是变量就报错,token是手动写的字符串就正常,后来发现是token多了一个回车。
token多了一个回车,但在h5和小程序就正确,APP下错误