Chrome extension “$ is not defined” error

前端 未结 4 1156
余生分开走
余生分开走 2020-12-10 04:17

I am getting an error \"$ is not defined\" when I am working on my chrome extension.

This is my manifest file:

   {
      \"name\": \"X\",
      \"d         


        
4条回答
  •  萌比男神i
    2020-12-10 04:53

    This is happening because you are calling your script before the jQuery file.
    The right one is this:

    {
      "name": "X",
      "description": "Snip this page",
      "version": "2.0",
      "permissions": [
        "activeTab"
      ],
      "background": {
        "scripts": ["background.js"],
        "persistent": false
      },
      "content_scripts":[{
        "matches" : [""],
        "js": ["jquery-2.0.2.js","yourscript.js"],
        "css": ["jquery.Jcrop.min.css"]
      }],
      "browser_action": {
        "default_title": "Snip this page"
      },
      "manifest_version": 2
    }
    

提交回复
热议问题