Requirejs main.js could not be found
Requirejs main.js could not be found
我开始学习JS,目前正在研究Require.JS。交易是这样的,我有一个简单的html页面和js:
<script data-main="js/main.js" src= "js/lib/require.js" type="text/javascript"></script>
我确实在root/js文件夹中有main.js,但由于某种原因,页面正在根目录中寻找main.js。错误:
*Failed to load resource file:///work/programs/brackets/4proj/main.js*
如果我把main.js放在根目录中(data main="main"),一切都会按预期进行,但我不想在根目录下有很多*js,甚至是2个js文件。我在require.js的例子中看到了这是可能的,但我没有成功。
我尝试过的:
/js/main.js
./js/main.js
//js/main.js
并且在没有扩展的情况下都是一样的它仍然不起作用。
这是项目结构。项目文件夹-4prog/
- /js
- /js/lib/<-jquery.js,require.js
- /css
- index.html
p.s.我使用的是Ubuntu+括号+铬
来自文档:
http://requirejs.org/docs/api.html#jsfiles
.js确实有需要的意义——它让它表现得像一条绝对的路径。
前缀"/"也是如此。
你没有明确提到尝试
<script data-main="js/main" src= "js/lib/require.js" type="text/javascript"></script>
这就是我的系统上的工作原理(来自文件:!),所以我只能假设要么你有其他事情发生,要么你没有尝试。
你没有提到你的require版本、你的操作系统或你的浏览器,所以可能就是这样,但更可能的是,在没有网络服务器的情况下,试图用require做一条绝对的路径会让你陷入困境。
相关文章:
- Requirejs main.js could not be found
- JavaScript文件在IIS上返回404 Not Found
- 可以对不属于't writive be shadowed
- react-css-module module not found
- Yii:TbCollapse 多链接(href = #collapse 并将状态更新为 be=“1”)
- express.JS .push cousing array to be undefined
- aurelia-bundler gulp.js can't be found
- grails3 jquery not found
- GeckoFX JSContext not found C#
- 我必须在 JS 中创建这种格式的数据.{ x: 1, y: 1, name: 'BE'},.
- Javascript:一个项目数组的sum-all-found.data()
- "未定义不是函数“;在.to Be功能
- Marionette: childViewContainer was not found
- .found('.foo').text()作为数组
- window.found(文本)用于Flash部分
- Js not found spring mvc
- Ajax POST MyUrl 404 (Not Found)
- 节点webkit中的Require('jquery ui')产生navigator not found错
- xmlhttp.send() returns 404 Not Found (Ajax)
- bundle.js cannot be found