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是的,它幫助!謝謝 –