如何在Chrome扩展程序中要求多个JavaScript文件,例如var file = require('example');

时间:2019-04-18 15:32:02

标签: javascript google-chrome google-chrome-extension

我正在开发google chrome扩展程序。我的内容脚本太大了。因此,我想将工作分为几个文件以保持工作整洁。

(我知道我不能在客户端使用require('example'))<,但找不到解决方法

问题出在这里

如果我需要一个js文件

const exampleFile = require('exampleFile');

在客户端,我收到一个错误:未捕获的ReferenceError:未定义require

当我尝试从 exampleFile

导出变量时,也会发生同样的情况
module.exports = someVariable;

这是我得到的错误:未捕获的ReferenceError:模块未定义

0 个答案:

没有答案