我创建了一个简单的扩展程序,用于存储当前的标签网址。我已经使用 chrome.storage.sync.set 来保存网址,但是当使用 chrome.storage.sync.get 时,它会弹出随机数而不是URL地址。我不确定从哪里得到这些数字?有什么想法吗?
代码如下:
add.js
var tabId = tab.id;
tabUrl = tab.url;
chrome.storage.sync.set({'urlLine': tabId}, function(){
alert('URL has been added the database!');
view.js
....
chrome.storage.sync.get('urlLine', function(data) {
alert(data.urlLine);