2013-02-19 103 views
2

如果我下载缩小的YUI3加载程序,包括它在我的background.html我得到以下错误:如何在Chrome扩展中使用YUI3?

未捕获的EvalError:拒绝,因为“不安全-EVAL”不是脚本所允许源的来评价一个字符串,如JavaScript在以下内容安全策略指令中:“script-src”self'chrome-extension-resource:“。

YUI3可以在扩展中使用吗?

回答

0

这就是我能够做到的。从git和我的扩展树克隆yui3和yui3-gallery,添加我需要的模块。然后从popup.html和background.html加载config.js。该文件看起来像这样:

YUI_config = { 
    filter: "raw", 
    base: "yui3/build/", 
    root: "yui3/build/", 
    comboBase: "/combo?", 
    combine: false, 
    groups: { 
     gallery: { 
      base: "yui3-gallery/build/", 
      root: "yui3-gallery/build/", 
      comboBase: "/combo?", 
      combine: false, 
      patterns: { 
       "gallery-": {}, 
       "gallerycss-": { type: "css" } 
      } 
     } 
    } 
}; 

现在一切正常!

+0

您是否有链接到您的代码? – 2013-06-01 06:19:33

1

它看起来像阻止你使用eval()。确保您的清单中有以下行。

"content_security_policy": "script-src 'self' 'unsafe-eval'; object-src 'self'"