Commit 4d79c2c0 by zhangxingmin

push

parent 2ed629ac
import App from './App.vue'; import App from './App';
import { createApp } from 'vue'
const app = createApp(App) // #ifndef VUE3
import Vue from 'vue'
// 添加挂载前检查 App.mpType = 'app'
const rootElement = document.getElementById('app') const app = new Vue({
if (!rootElement) { ...App
console.error('⚠️ 未找到挂载元素 #app')
// 创建备用挂载点
const fallbackApp = document.createElement('div')
fallbackApp.id = 'app'
document.body.appendChild(fallbackApp)
app.mount('#app')
} else {
console.log('✅ 找到挂载元素 #app')
app.mount('#app')
}
// 添加应用加载完成事件
window.addEventListener('DOMContentLoaded', () => {
console.log('🚀 DOM内容加载完成')
if (document.getElementById('app').childElementCount === 0) {
console.warn('⚠️ 应用挂载点为空,可能未正确渲染')
// 显示错误信息
const errorDiv = document.createElement('div')
errorDiv.style = "padding:20px;color:red;font-size:20px;text-align:center;"
errorDiv.innerHTML = `
<h1>应用初始化失败</h1>
<p>请检查控制台错误信息</p>
<p>当前路径: ${window.location.href}</p>
<p>Base路径: /cffp/</p>
`
document.getElementById('app').appendChild(errorDiv)
}
}) })
app.$mount()
// #endif
// H5环境特定代码 // #ifdef VUE3
if (typeof window !== 'undefined') { import { createSSRApp } from 'vue'
const firstEntryUrl = window.location.href.split('#')[0] export function createApp() {
window.sessionStorage.setItem('firstEntryUrl', firstEntryUrl) const app = createSSRApp(App)
console.log('🌐 记录首次访问URL:', firstEntryUrl) return {
app
}
} }
// #endif
//#ifdef H5
window.sessionStorage.setItem('firstEntryUrl',window.location.href.split('#')[0])
// #endif
...@@ -61,7 +61,8 @@ ...@@ -61,7 +61,8 @@
"uuid": "^11.1.0", "uuid": "^11.1.0",
"vant": "^4.9.21", "vant": "^4.9.21",
"vite-plugin-svg-icons": "^2.0.1", "vite-plugin-svg-icons": "^2.0.1",
"vue": "^3.5.18", "vue": "^2.6.14",
"@dcloudio/uni-app": "^2.0.0",
"vue-cropper": "^1.0.8", "vue-cropper": "^1.0.8",
"vue-router": "^4.5.1", "vue-router": "^4.5.1",
"vue3-count-to": "^1.1.2", "vue3-count-to": "^1.1.2",
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment