Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chrome插件开发踩坑总结 #32

Open
SunShinewyf opened this issue Nov 6, 2017 · 0 comments
Open

chrome插件开发踩坑总结 #32

SunShinewyf opened this issue Nov 6, 2017 · 0 comments

Comments

@SunShinewyf
Copy link
Owner

前言:之前并没有接触过chrome扩展,第一次接触chrome插件也只是使用二维码生成器,然后是老大给了一篇教程之后开始尝试,然后觉得还是蛮好玩的,便尝试了一个demo,是对自己收藏的书签进行美化还有添加的一些操作

对于chrome开发入门的一些知识,直接看教程这里即可,这里不赘述。

下面记录一些开发过程中踩过的坑以及解决方案:

  • manifest.json文件中,对于图标的定义,仅仅定义一个default-icon并不能生效,还需要定义一个icons的值,例如:
 "icons": {
      "48": "icon.png"
 },
  • chrome.storage.sync undefined?

这是因为在manifest.json文件中没有声明如下定义:

 "permissions": [
   "storage"
 ],
  • 对于获取书签数据,需要在manifest.json中定义permissions,否则会获取不到数据
 "permissions": [
    "storage",
    "bookmarks"
  ],
  • 提示“Not allowed to load local resource: chrome://favicon/”

查找错误原因,stackoverflow给出的讨论是需要在manifest.json中添加权限,讨论地址,按照讨论方案设置如下权限:

 "permissions": [
   "storage",
   "bookmarks",
   "http://*/",
   "chrome://favicon/",
   "chrome://favicon/*",
   "tabs", 
   "<all_urls>"
 ],

仍然不生效,还在继续查找原因

后面的一些经验和总结会不断汇总到这里

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant