找回密码
 立即注册
搜索

互动交流 快应用如何设置环境变量

2
回复
1034
查看
[复制链接]

1

主题

3

帖子

20

积分

 楼主| 2020-12-28 11:08:34 显示全部楼层 |阅读模式
问题描述 我想设置全局环境变量,但是一直失败。 代码 quickapp.config.js 在test页面打印环境变量ORIGIN 结果
回复

使用道具 举报

1

主题

3

帖子

20

积分

 楼主| 2020-12-28 11:11:54 显示全部楼层
图片被吃了
回复

使用道具 举报

1

主题

3

帖子

20

积分

 楼主| 2020-12-28 11:12:59 显示全部楼层
配置代码 module.exports = { webpack: { resolve: { alias: { '@': path.resolve(__dirname, 'src'), components: path.resolve(__dirname, 'src/components'), }, }, plugins: [ // 自动替换代码中的变量 new webpack.DefinePlugin({ ORIGIN: 'https://test.com', }), ], }, }; 测试页面代码 console.log('ORIGIN', ORIGIN); 结果 Uncaught SyntaxError: missing ) after argument list at Object../src/pages/test-page3/index.js (index.js:370) at __webpack_require__ (index.js:23) at __scriptModule__ (index.ux?0375:16) at eval (index.ux?e573:8) at Ki (web.js:1) at web.js:1 at r (web.js:1) at eval (index.ux?e573:7) at Object../src/pages/test-page3/index.ux?uxType=page (index.js:381) at __webpack_require__ (index.js:23) electron/js2c/renderer_init.js:114 Uncaught TypeError: r.process.listenerCount is not a function at window.onerror (electron/js2c/renderer_init.js:114)
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册