// src/main.js import Vue from 'vue' import App from './App' import router from './router' import store from './store' // 确保路径正确 import '@/styles/index.scss' // 导入 request.js 并挂载到 Vue 原型 import http from '@/utils/request' Vue.config.productionTip = false // 正确挂载 $http 方法 - 关键修复 Vue.prototype.$http = http // 初始化应用 new Vue({ router, store, render: h => h(App), created() { // 验证 $http 是否已挂载 console.log('$http available in root instance:', typeof this.$http.get === 'function') }, mounted() { // 确保路由初始化完成 if (!router.currentRoute) { console.warn('路由未初始化,重定向到默认页面') router.push('/pages/novel/list') } } }).$mount('#app')