Chrome拡張機能でRequre.jsを使用しようとしています。
これが私のマニフェストです:
{
"name":"my extension",
"version":"1.0",
"manifest_version":2,
"permissions": ["http://localhost/*"],
"web_accessible_resources": [
"js/test.js"
],
"content_scripts":[
{
"matches":["http://localhost/*"],
"js":[
"js/require.js",
"js/hd_init.js"
]
}
]
}
hd_init.js
console.log("hello, i'm init");
require.config({
baseUrl: chrome.extension.getURL("js")
});
require( [ "js/test"], function ( ) {
console.log("done loading");
});
js / test.js
console.log("hello, i'm test");
define({"test_val":"test"});
これは私がコンソールで取得するものです:
hello, i'm init chrome-extension://bacjipelllbpjnplcihblbcbbeahedpo/js/hd_init.js:8
hello, i'm test test.js:8
**Uncaught ReferenceError: define is not defined test.js:2**
done loading
そのため、ファイルはロードされますが、「define」関数は表示されません。これは、ある種のスコープエラーのように見えます。ローカルサーバーで実行すると、正常に動作します。
何か案は?