当前位置: 首页 > news >正文

外贸做哪个网站平台seo排名工具外包

外贸做哪个网站平台,seo排名工具外包,手机网站自适应宽度,厦门建设网站的uniapp踩坑 uni.showToast 和 uni.showLoading 一、问题描述 uni.showLoading 和 uni.showToast 混合使用时,showLoading和showToast会相互覆盖对方,调用hideLoading时也会将toast内容进行隐藏。 二、触发条件 1.uniapp中使用自己封装的axois&#x…

uniapp踩坑 uni.showToast 和 uni.showLoading

一、问题描述

  • uni.showLoading 和 uni.showToast 混合使用时,showLoading和showToast会相互覆盖对方,调用hideLoading时也会将toast内容进行隐藏。

二、触发条件

  • 1.uniapp中使用自己封装的axois,拦截器使用 uni.showToast 做异常信息处理
  • 2.业务中使用 uni.showLoading 做业务处理
  • 3.当请求异常被catch抓到,使用 uni.hideLoading 清除 loading 时,异常信息 toast 会被覆盖掉。

三、解决思路

  • 小程序将Toast和Loading放到同一层渲染引起的,而且缺乏一个优先级判断,也没有提供Toast、Loading是否正在显示的接口供业务侧判断。所以我们自己实现这套逻辑,判断其中有一个已经渲染,泽不执行另一个。

四、实现方案

1.封装一下toast和loading

/*** 显示消息提示框* @param title* @param options* @constructor*/
export function Toast(title: string, options?: Partial<UniApp.ShowToastOptions>) {uni.showToast({title,duration: 1500,icon: 'none',mask: true,...options,});
}/*** 隐藏消息提示框*/
export function HideToast() {uni.hideToast();
}/*** 显示 loading 提示框* @param title* @param options* @constructor*/
export function Loading(title: string, options?: Partial<UniApp.ShowLoadingOptions>) {uni.showLoading({title,mask: true,...options,});
}/*** 隐藏 loading 提示框*/
export function HideLoading() {uni.hideLoading();
}

2.要加个变量控制toast和loading的优先级,最简单就是通过vue的全局状态管理来控制

export const usePromptStore = defineStore({id: 'promptStore',state: (): IState => ({isShowLoading: false,isShowToast: false,}),getters: {getIsShowLoading: (state) => state.isShowLoading,getIsShowToast: (state) => state.isShowToast,},actions: {setIsShowLoading(val: boolean) {this.isShowLoading = val;},setIsShowToast(val: boolean) {this.isShowToast = val;},},
});

3.改造一下封装的toast和loading

/*** 显示消息提示框* @param title* @param options* @constructor*/
export function Toast(title: string, options?: Partial<UniApp.ShowToastOptions>) {const promptStore = usePromptStore();if (promptStore.disabledToast) return;if (promptStore.isShowLoading) {// Toast优先级更高HideLoading();}promptStore.setIsShowToast(true);uni.showToast({title,duration: 1500,icon: 'none',mask: true,...options,});const timer = setTimeout(() => {promptStore.setIsShowToast(false);clearTimeout(timer)}, 1500);
}/*** 隐藏消息提示框*/
export function HideToast() {const promptStore = usePromptStore();promptStore.setIsShowToast(false);uni.hideToast();
}/*** 显示 loading 提示框* @param title* @param options* @constructor*/
export function Loading(title: string, options?: Partial<UniApp.ShowLoadingOptions>) {const promptStore = usePromptStore();if (promptStore.isShowToast) {// Toast优先级更高return;}promptStore.setIsShowLoading(true);uni.showLoading({title,mask: true,...options,});
}/*** 隐藏 loading 提示框*/
export function HideLoading() {const promptStore = usePromptStore();if (promptStore.isShowToast) {// Toast优先级更高return;}promptStore.setIsShowLoading(false);uni.hideLoading();
}
http://www.dinnco.com/news/49969.html

相关文章:

  • 公益网站建设方案自助发稿
  • 企业网站开发成本专业网站优化外包
  • 有域名怎样建设网站seo推广软件代理
  • 做公司网站需要注意什么steam交易链接在哪
  • 东莞做网站哪个公司最好fifa最新世界排名
  • 阆中网站建设搜索引擎营销的优缺点
  • 网站开发毕设文档seo基础理论
  • 做实验用哪些国外网站网站的营销策略
  • 在线制作图片背景当阳seo外包
  • 本溪市城乡规划建设委员会网站seo整体优化
  • 网站系统改教程百度贴吧首页
  • 广州 网站开发 骏域一键开发小程序
  • java网站开发福建企业seo推广
  • 做一的同志小说网站有哪些志鸿优化设计
  • 局网站建设管理制度如何去做网络推广
  • 广州市哪有做网站的网站建设品牌公司
  • 网站建设中布局“跨年”等关键词搜索达年内峰值
  • 委托网络公司做网站的合同优化是什么意思
  • 现代网站制作steam交易链接在哪复制
  • 深圳龙华建设发展公司上海seo培训中心
  • 设计类网站apphtml网页模板
  • 阿里云网站公安备案最近新闻今日头条
  • 网站建设运营方案企业文化标语经典
  • 网站编辑器哪个好用网络营销的三种方式
  • 有什么平台可以销售产品小红书seo排名
  • 陵水网站建设品牌网络营销策划
  • 做网站需要哪些素材短视频平台推广
  • 做像淘宝网的网站中国知名网站排行榜
  • 站长之家ip查询工具seo一个月赚多少钱
  • wordpress管理员权限获取西藏自治区seo 标题 关键词优化