20240123 uniapp获取当前小程序APPID
uni.getAccountInfoSync().miniProgram.appId
20231123 uniapp返回上个页跨页面传递参数
uni.$emit('returnData',111);
uni.$on('returnData',res=>{
console.log('参数',res)
})
uni.$off('returnData')
20230321 scrollview设置scroll-top=0不生效
this.scrollTop = this.scrollTop===0?-1:0;
20221010 uniapp indicator-dots样式修改
<style>
/* 默认指示点的样式 */
.screen-body .wx-swiper-dot {
width: 6rpx;
height: 6rpx;
background: #FFB949;
border-radius: 4rpx;
}
/* 选中指示点的样式 */
.screen-body .wx-swiper-dot.wx-swiper-dot-active {
width: 24rpx;
height: 6rpx;
background: #FF8933;
border-radius: 4rpx;
}
</style>
20221002 uniapp遮罩弹出时禁止页面滚动
<view class="popup" catchtouchmove="true"></view>
20220505 h5配置修改index.html模板路径样式错乱
保持模板路径默认为空,不做任何修改。
在unpackage目录下找到编译打包后的index.html进行修改。
这样配置网站图标和引入客服代码就都会生效了。
20220316 this.$parent在H5端不生效
原因:在uni中 <view></view> 标签也是一个组件
解决:嵌套几层就多写几个$parent
20220216 微信小程序保存图片到本地
// 保存图片到本地
saveShareImage() {
// 如果是网络图片 需先下载至本地
uni.downloadFile({
url: this.posterImgSrc,
success(res) {
console.log(res.tempFilePath)
// 如果已生成本地图片路径 可直接到这一步保存
let filePath = res.tempFilePath;
uni.saveImageToPhotosAlbum({
filePath: filePath,
success(res) {
uni.showToast({
title: '保存成功'
});
},
fail: function (err) {
if (err.errMsg) {//重新授权弹框确认
uni.showModal({
title: '提示',
content: '您需要允许授权才能保存图片',
showCancel: false,
success(res) {
if (res.confirm) {//重新授权弹框用户点击了确定
uni.openSetting({//进入小程序授权设置页面
success(settingdata) {
console.log(settingdata)
if (settingdata.authSetting['scope.writePhotosAlbum']) {//用户打开了保存图片授权开关
uni.saveImageToPhotosAlbum({
filePath: filePath,
success(res) {
uni.showToast({
title: '保存成功'
});
}
})
} else {//用户未打开保存图片到相册的授权开关
uni.showModal({
title: '温馨提示',
content: '授权失败,请稍后重新获取',
showCancel: false,
})
}
}
})
}
}
})
}
},
})
},
})
},
20220105 通过 setTabBarItem 动态设置tabBar
let tabBarOptions = {
index: 1,
text: '首页222',
pagePath: "/pages/tabbar/home",
iconPath: "static/tabbar/home.png",
selectedIconPath: "static/tabbar/home2.png",
};
uni.setTabBarItem(tabBarOptions);
20211231 迁移小程序是需要注意事项
1.切换小程序ID和密钥
2.后台配置安全域名 https://api.bspapp.com
3.前端网页托管,需要再跨域配置处加入临时生成的域名
20211228 连接本地调试服务失败,请检查主机是否和客户端在同一局域网下
解决方式 重启hbuilder 重新编译打包
20211222 button去掉默认的边框和背景色
button{
background: none;
border: none;
padding: 0;
}
button::after{
border: none;
}
20210121 uniapp获取当前页面路由及参数
let routes = getCurrentPages(); // 获取当前打开过的页面路由数组
let curRoute = routes[routes.length - 1].route; //获取当前页面路由
let curParam = routes[routes.length - 1].options; //获取路由参数
20211201 uniapp中 onLaunch 异步方法与 onLoad / onReady / mounted 执行顺序问题(登录获取token等)
登录方法写在app.vue的 onLaunch 周期里,在页面组件 onLoad 周期里获取用户信息,会发现 onLoad 早于 onLaunch 执行,拿不到用户信息,解决方法网上有,但是个人感觉还是太麻烦了。