6***@qq.com
6***@qq.com
  • 发布:2024-03-25 11:34
  • 更新:2024-06-13 17:16
  • 阅读:122

【报Bug】showToast在main.js不显示

分类:uni-app

产品分类: uniapp/H5

PC开发环境操作系统: Windows

PC开发环境操作系统版本号: Windows 10 专业版

HBuilderX类型: 正式

HBuilderX版本号: 3.99

浏览器平台: Chrome

浏览器版本: 123.0.6312.58

项目创建方式: HBuilderX

App下载地址或H5⽹址: https://87x434258u.goho.co/

示例代码:
import App from './App'  

// #ifndef VUE3  
import Vue from 'vue'  
import './uni.promisify.adaptor'  
Vue.config.productionTip = false  
App.mpType = 'app'  

uni.showLoading({  
    title:'加载中'  
})  

// uni.showToast({  
//  title:'123',  
//  icon:'none'  
// })  
const app = new Vue({  
  ...App  
})  
app.$mount()  
// #endif  

// #ifdef VUE3  
import { createSSRApp } from 'vue'  
export function createApp() {  
  const app = createSSRApp(App)  
  return {  
    app  
  }  
}  
// #endif  

操作步骤:

在main.js直接调用showToast或showLoading不显示,通过setTimeout(()=>{},0)调用可以显示

预期结果:

希望可以直接调用showToast或showLoading, 能正常显示

实际结果:

mian.js直接调用showToast或showLoading不显示

bug描述:

showToast和showLoading在main.js直接调用不显示, 通过setTimeout(()=>{},0)调用没问题。希望在mian.js可以直接调用。

2024-03-25 11:34 负责人:无 分享
已邀请:
CoderChenMM

CoderChenMM

不生效的根本原因就是调用uni.showToast()这个方法时,vue实例并没有挂载到页面上,因此此时dom中没有<uni-app></uni-app>这个节点,而该方法又依赖于这个节点去挂载弹窗元素,所以showToast()没有按照预期显示内容。另外uni这个对象中有很多的方法会涉及到dom操作,基本上都需要在挂载dom成功以后才能生效。

沈工

沈工

不能在main.js调用

piaoyi_UI

piaoyi_UI - 【插件开发】【专治疑难杂症】【多款插件已上架:https://ext.dcloud.net.cn/publisher?id=193663(微信搜索飘逸科技UI小程序直接体验)】【骗子请绕道】问题咨询请加QQ群:120594820,代表作灵感实用工具小程序

没有这样的使用方法

要回复问题请先登录注册