z***@qq.com
z***@qq.com
  • 发布:2022-02-21 12:44
  • 更新:2022-11-25 00:40
  • 阅读:1523

Uncaught ReferenceError: ROUTES is not defined

分类:uni-app

Uncaught ReferenceError: ROUTES is not defined

2022-02-21 12:44 负责人:无 分享
已邀请:
膨胀的木鱼

膨胀的木鱼 - 嚣张的小毛驴

const TransformPages = require('uni-read-pages')
const {
webpack
} = new TransformPages()
let pluginsDev = new webpack.DefinePlugin({
ROUTES: webpack.DefinePlugin.runtimeValue(() => {
const tfPages = new TransformPages({
includes: ['path', 'name', 'aliasPath']
});
return JSON.stringify(tfPages.routes)
}, true)
})
let publicPath = './'
module.exports = {
transpileDependencies: ['uview-ui'],
configureWebpack: {
resolve: {
alias: {
'/': '@',
}
},
},
publicPath: publicPath,
lintOnSave: true,
// 配置转发代理
devServer: {
proxy: {
'/admin': {
target: url,
changeOrigin: true, //允许跨域
pathRewrite: {
'^/admin': '/'
}
}
// v2.7.0 不需在配置前端代理
}
},
productionSourceMap: false, // 生产打包时不输出map文件,增加打包速度
configureWebpack: config => {
devtool: 'cheap-module-eval-source-map'
if (process.env.NODE_ENV === 'production') {
config.optimization.minimizer[0].options.terserOptions.compress.warnings = false
config.optimization.minimizer[0].options.terserOptions.compress.drop_console = true
config.optimization.minimizer[0].options.terserOptions.compress.drop_debugger = true
config.optimization.minimizer[0].options.terserOptions.compress.pure_funcs = ['console.log']
}

///////////////////////////////////超级注释 , 看这里 解决方法如下
config.plugins.push(pluginsDev)
}
}

  • cwdnb

    看这位老哥的,不会改配置的直接把这坨代码复制粘贴到vue.config.js

    2022-08-19 15:24

hhyang

hhyang

  • i***@chetell.com

    请问你怎么解决的

    2022-06-07 11:02

  • 哈哈哈yo

    回复 i***@chetell.com: 你好,你解决这个问题了吗

    2022-06-16 19:41

1***@qq.com

1***@qq.com

你好,请问你最终怎样解决的

PandaMan

PandaMan

看看 manifest.json,是否开启了 纯nvue项目 原生渲染

哈哈哈yo

哈哈哈yo - 哈哈哈

有解决方案了吗? 什么原因啊,我也碰到了

d***@163.com

d***@163.com

需要配置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', 'meta','aliasPath']
});
return JSON.stringify(tfPages.routes)
}, true )
})
]
}
}

7***@qq.com

7***@qq.com

我就想知道,有人成功了的吗?
router.js:6 Uncaught ReferenceError: ROUTES is not defined
router.js:6 Uncaught ReferenceError: ROUTES is not defined
router.js:6 Uncaught ReferenceError: ROUTES is not defined
router.js:6 Uncaught ReferenceError: ROUTES is not defined
router.js:6 Uncaught ReferenceError: ROUTES is not defined
router.js:6 Uncaught ReferenceError: ROUTES is not defined
router.js:6 Uncaught ReferenceError: ROUTES is not defined
router.js:6 Uncaught ReferenceError: ROUTES is not defined
router.js:6 Uncaught ReferenceError: ROUTES is not defined
router.js:6 Uncaught ReferenceError: ROUTES is not defined
router.js:6 Uncaught ReferenceError: ROUTES is not defined

7***@qq.com

7***@qq.com

朋友们,VUE3.0 是不得行的,要VUE2.0

1***@qq.com

1***@qq.com

是插件缺失问题

1***@qq.com

1***@qq.com

是插件缺失问题。uni-read-pages插件是在vue.config.js文件中配置的,外面的编译环境不能直接加载内部vue.config.js文件。
可以添加日志来确认该文件有没有在编译时执行。
可以将该文件复制到编译目录下然后安装uni-read-pages的依赖包,之后即可打包。请路过高手弄一个灵活加载然后@我

1***@qq.com

1***@qq.com

这个问题我遇到了,解决方法:

vue.config.js应当放在根目录下,不要放在src目录下。

要回复问题请先登录注册