SilurianYang / uni-simple-router

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

Cannot find name 'ROUTES' #422

Closed hewson99 closed 1 year ago

hewson99 commented 2 years ago

const router = createRouter({ platform: process.env.UNI_PLATFORM, routes: [...ROUTES] });

sfc.d.ts文件已经加上了声明 import Vue from 'vue' declare module "vue/types/options" { type Hooks = App.AppInstance & Page.PageInstance; interface ComponentOptions extends Hooks { /**

SilurianYang commented 2 years ago

uni-read-pages 有配置吗?

//vue.config.js
const TransformPages = require('uni-read-pages')
const {webpack} = new TransformPages()
module.exports = {
    configureWebpack: {
        plugins: [
            new webpack.DefinePlugin({
                ROUTES: webpack.DefinePlugin.runtimeValue(() => {
                    const tfPages = new TransformPages({
                        includes: ['path', 'name', 'aliasPath']
                    });
                    return JSON.stringify(tfPages.routes)
                }, true )
            })
        ]
    }
}
hewson99 commented 2 years ago

SilurianYang commented 2 years ago

上传一个demo过来我这边排查下