SilurianYang / uni-simple-router

A simple, lightweight 'uni-app' routing plugin
https://v2.hhyang.cn/v2/
MIT License
749 stars 163 forks source link

配置2.0.7版本的uni-simple-router后导致微信小程序端uview-ui无法引入,h5端正常 #423

Closed Grolia closed 2 years ago

Grolia commented 2 years ago

问题描述 先配置引入uview-ui,使用组件没问题。但是引入2.0.7版本的uni-simple-router并配置好之后导致小程序端无法读取uview-ui的组件

[Vue warn]: Error in beforeCreate hook: "TypeError: Cannot read property 'page' of undefined" found in ---> at node_modules/uview-ui/components/u-calendar/u-calendar.vue pages/index/index.vue(env: Windows,mp,1.06.2209070; lib: 2.26.0)

[Vue warn]: Error in beforeCreate hook: "TypeError: Cannot read property 'page' of undefined" found in ---> at node_modules/uview-ui/components/u-popup/u-popup.vue

at node_modules/uview-ui/components/u-calendar/u-calendar.vue pages/index/index.vue(env: Windows,mp,1.06.2209070; lib: 2.26.0) **复现步骤** **vue.config.js** const TransformPages = require('uni-read-pages') const { webpack } = new TransformPages() module.exports = { configureWebpack: { plugins: [ //simple-router配置 new webpack.DefinePlugin({ ROUTES: webpack.DefinePlugin.runtimeValue(() => { const tfPages = new TransformPages({ includes: ['path', 'name', 'meta', 'aliasPath'] }); return JSON.stringify(tfPages.routes) }, true) }), ] } } **main.js** import Vue from 'vue' import App from './App' import uView from "uview-ui"; Vue.use(uView); import { router, RouterMount } from './router/index.js'; Vue.use(router); Vue.config.productionTip = false App.mpType = 'app' const app = new Vue({ ...App }) // #ifdef H5 RouterMount(app, router, '#app') // #endif // #ifndef MP-WEIXIN app.$mount(); // #endif **router/index.js** import { RouterMount, createRouter } from 'uni-simple-router'; const router = createRouter({ platform: process.env.VUE_APP_PLATFORM, routes: [...ROUTES] }); router.beforeEach((to, from, next) => {}) export { router, RouterMount } **系统信息:** - uni-simple-router版本:v2.0.7 - uview-ui版本:1.8.4