我可以从 Chrome Packaged App 的后台页面调用变量或函数吗?

iam*_*nut 1 html javascript google-chrome-app

我的 Chrome Packaged App 有 2 个 JavaScript 文件。

1. background.js 是一个由 manifest.json 调用的主要 JavaScript 文件

var foo = 'sss';

function bar(a,b) {
    return a+b;
}

chrome.app.runtime.onLaunched.addListener(function() {
  chrome.app.window.create('index.html', {
    bounds: {
      width: 500,
      height: 300
    }
  });
});
Run Code Online (Sandbox Code Playgroud)

2. app.js 是 index.html 的控制器

问题:我可以在app.js 中background.js调用变量“foo”或函数“bar”吗?

附注。或者有什么解决方案可以在页面之间传输价值,例如chrome.storage