当我处理我的chrome扩展时,我收到错误"$ is not defined".
这是我的清单文件:
{
"name": "X",
"description": "Snip this page",
"version": "2.0",
"permissions": [
"activeTab"
],
"background": {
"scripts": ["background.js"],
"persistent": false
},
"content_scripts":[{
"matches" : ["<all_urls>"],
"js": ["jquery-2.0.2.js","jquery.Jcrop.js"],
"css": ["jquery.Jcrop.min.css"]
}],
"browser_action": {
"default_title": "Snip this page"
},
"manifest_version": 2
}
Run Code Online (Sandbox Code Playgroud)
这是我的background.js文件:
chrome.browserAction.onClicked.addListener(function(tab){
// No tabs or host permissions needed!
chrome.tabs.executeScript({
file: 'content.js'
});
});
Run Code Online (Sandbox Code Playgroud)
最后,触发错误的文件:content.js
console.log('1');
var jcropapi, boundx, boundy;
$('body').attr('id', 'target');
$(document).ready(function(){
$('target').Jcrop();
console.log('4');
document.onkeydown = function(){
if(window.event.keyCode==13){
console.log('enter');
}
};
});
Run Code Online (Sandbox Code Playgroud)
从我的理解,这发生了因为JQuery没有加载.但是,我正在清单中正确加载它,jquery.js也是在清单内容脚本中调用的第一个文件.请帮我调试.谢谢!
我在线跟踪教程,我有两种方法可以向Google Places API提交查询.不幸的是,我试图回复,但它无法正常工作.我在代码中有一些调试号.但是,这是代码.
-(void) queryGooglePlaces{
NSString *url = @"https://maps.googleapis.com/maps/api/place/search/json?location=-33.8670522,151.1957362&radius=500&types=food&name=harbour&sensor=false&key=myKey";
//Formulate the string as a URL object.
NSURL *googleRequestURL=[NSURL URLWithString:url];
NSLog(@"1.5");
// Retrieve the results of the URL.
dispatch_async(kBgQueue, ^{
NSData* data = [NSData dataWithContentsOfURL: googleRequestURL];
[self performSelectorOnMainThread:@selector(fetchedData:) withObject:data waitUntilDone:YES];
});
NSLog(@"2");
}
-(void)fetchedData:(NSData *)responseData {
//parse out the json data
NSError* error;
NSDictionary* json = [NSJSONSerialization
JSONObjectWithData:responseData
options:kNilOptions
error:&error];
//The results from Google will be an array obtained from the NSDictionary object with the key "results".
NSArray* places …
Run Code Online (Sandbox Code Playgroud) 我正在学习嵌入式系统类简介.在我阅读时,我遇到了一个关于进位和溢出位实现的有趣问题.我知道什么是进位和溢出位,但我想不出有人会使用进位的情况.我认为的一个原因是调整记忆.有人可以解释这个问题吗?
谢谢!
我尝试安装分发或安装工具,这必须在Raspberry Pi上安装pip之前完成.
使用的命令是 $ curl http://python-distribute.org/distribute_setup.py | python
但是我收到以下错误.如果需要,我可以复制整个终端脚本.
[Errno 13] Permission denied: '/usr/local/lib/python2.7/dist-packages/test-easy-install-2082.pth'
Run Code Online (Sandbox Code Playgroud)
谢谢你的帮助!
你们知道一种使用javascript将base64字符串转换为PNG的方法吗?我基本上想在网站上显示它.
示例字符串:
"imageData": "iVBORw0KGgoAAAANSUhEUgAAABQAAAAUCAYAAACNiR0NAAAAAXNSR0IB2cksfwAAAAlwSFlzAAAOxAAADsQBlSsOGwAAAC9JREFUOI1jYaAyYKGdgYse/6fIpDhZRlQDqQRGDRw1cNTAUQPpbSC0PKOegVQCADCrA81JwUxoAAAAAElFTkSuQmCC"
Run Code Online (Sandbox Code Playgroud)