Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/reactjs/22.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何获取manifest.json来读取src文件夹中的文件_Javascript_Reactjs_Google Chrome Extension_Manifest.json - Fatal编程技术网

Javascript 如何获取manifest.json来读取src文件夹中的文件

Javascript 如何获取manifest.json来读取src文件夹中的文件,javascript,reactjs,google-chrome-extension,manifest.json,Javascript,Reactjs,Google Chrome Extension,Manifest.json,我有一个文件,当用户从google chrome扩展弹出窗口中弹出标签时,我想在后台运行该文件,但我无法将我的Timer.js文件从我的react应用程序src移动到公共位置,我无法移动manifest.jsonvice vera 我尝试过链接我的Timer.js比如。/src/components/Timer.js和src/components/Timer.js,但这对我也不起作用 我有什么遗漏吗?过去几天我一直在搜索,没有发现任何类似的问题 manifest.json { "man

我有一个文件,当用户从google chrome扩展弹出窗口中弹出标签时,我想在后台运行该文件,但我无法将我的
Timer.js
文件从我的react应用程序
src
移动到公共位置,我无法移动
manifest.json
vice vera

我尝试过链接我的
Timer.js
比如
。/src/components/Timer.js
src/components/Timer.js
,但这对我也不起作用

我有什么遗漏吗?过去几天我一直在搜索,没有发现任何类似的问题

manifest.json

{
"manifest_version": 2,
"name": "Study Buddy",
"author": "sam",
"version":"1.0.1",
"description": "All in one app for all your studying needs!",
"icons":{
  "16": "favicon.ico",
  "48": "favicon.ico",
  "128": "favicon.ico"
},
"browser_action":{
  "default_popup":"index.html",
  "default_title": "Study Buddy"
},
"background": {
  "scripts": [
    "../src/components/Timer.js"
  ]
}
}


您不能在扩展文件夹外加载资源:(“./src/components/Timer.js”)。有人刚刚问了你的问题!!!我现在明白了,但这并不能帮助我找到解决方案。如果Timer.js是一个静态文件,您可以将该文件复制到扩展名文件夹中。如果没有,您可以尝试以以下方式在本地后台脚本中创建脚本:myScript=document.createElement('script')、myScript.src=“.src./src/components/Timer.js”、document.head.appendChild(script)/*没有任何担保*/Timer.js具有react导入,这会在我将其移动到公用文件夹时导致错误。感谢您的输入,我将尝试在公用文件夹中创建background.js,看看是否可以调用timer.js!您的公用文件夹基本上是一个可分发的,这意味着这是您的最终代码所在的位置。您通常将源代码编译成公共文件。创建一个脚本,将源代码编译到公用文件夹中,或者如果源代码是最终输出,则创建一个脚本,以便在每次执行生成时将源代码复制到公用文件夹中。