路由可以动态配置吗?



  • 我希望 app.js 里的页面路由可以动态配置。H5和小程序里的路由有不一样的配置。当我把pages 赋予一个变量,就会报错。什么charAt...



  • 文件变动 src/app.js
    TypeError: Cannot read property 'charAt' of undefined
    at Object.exports.addLeadingSlash (/usr/local/lib/node_modules/@tarojs/cli/dist/h5/helper.js:51:40)
    at exit (/usr/local/lib/node_modules/@tarojs/cli/dist/h5/index.js:603:42)
    at NodePath._call (/usr/local/lib/node_modules/@tarojs/cli/node_modules/babel-traverse/lib/path/context.js:76:18)
    at NodePath.call (/usr/local/lib/node_modules/@tarojs/cli/node_modules/babel-traverse/lib/path/context.js:48:17)
    at NodePath.visit (/usr/local/lib/node_modules/@tarojs/cli/node_modules/babel-traverse/lib/path/context.js:117:8)
    at TraversalContext.visitQueue (/usr/local/lib/node_modules/@tarojs/cli/node_modules/babel-traverse/lib/context.js:150:16)
    at TraversalContext.visitSingle (/usr/local/lib/node_modules/@tarojs/cli/node_modules/babel-traverse/lib/context.js:108:19)
    at TraversalContext.visit (/usr/local/lib/node_modules/@tarojs/cli/node_modules/babel-traverse/lib/context.js:192:19)
    at Function.traverse.node (/usr/local/lib/node_modules/@tarojs/cli/node_modules/babel-traverse/lib/index.js:114:17)
    at Object.traverse [as default] (/usr/local/lib/node_modules/@tarojs/cli/node_modules/babel-traverse/lib/index.js:79:12)
    at Compiler.processEntry (/usr/local/lib/node_modules/@tarojs/cli/dist/h5/index.js:435:33)
    at Compiler.processFiles (/usr/local/lib/node_modules/@tarojs/cli/dist/h5/index.js:999:44)
    at FSWatcher.watcher.on.on.filePath (/usr/local/lib/node_modules/@tarojs/cli/dist/h5/index.js:173:18)
    at emitOne (events.js:116:13)
    at FSWatcher.emit (events.js:211:7)
    at FSWatcher.<anonymous> (/usr/local/lib/node_modules/@tarojs/cli/node_modules/chokidar/index.js:199:15)



  • 83160471-070c-465d-b23d-e5513a0b5e56-image.png

    concat一下也不行,通过报错信息看,这里是被编译成字符串还是怎么回事。我想根据环境变量配置动态的路由。有什么办法?



  • 我需要


登录后回复