0
var getShortenedUrl = function() {
chrome.tabs.getSelected(null, function (tab) {
var request_data = {
'command': 'generate',
'params': {
'url': tab.url,
'code': text_field.value
}
}
chrome.extension.sendRequest(request_data, function (data) {
switch (data.status) {
case 'OK':
setTextField(data.shortened_url)
bindBtnToCoopy()
chrome.storage.local.get(data.shortened_url, function (arr) {
if (!arr[data.shortened_url]) {
chrome.storage.local.set(
{data.shortened_url:
tab.url}) /* <-- this thing throws an error */
}
})
break
/* ... */
}
})
})
}
看到https://github.com/noformnocontent/git-io-chrome/blob/master/chrome/popup.js#L96Chrome扩展 “未捕获的SyntaxError:意外的标识” 关于`storageArea.set`
,如果我评论的chrome.storage.local.set
一部分出来,一切都是 “完美”
你的换行是冒险的。并使用分号! – Bergi
[chrome.storage.local.set使用变量键名称]的可能重复(http://stackoverflow.com/questions/11692699/chrome-storage-local-set-using-a-variable-key-name) – pimvdb
@pimvdb是的,它帮助!谢谢 –