Chrome 离线应用开发方法详解

1,182 阅读1分钟
原文链接: www.36nu.com

假如在文件hello-world下做开发

1  创建manifest.json文件

{
  "name": "Hello World!",
  "description": "My first Chrome App.",
  "version": "0.1",
  "manifest_version": 2,
  "app": {
    "background": {
      "scripts": ["background.js"]
    }
  },
  "icons": { "16": "calculator-16.png", "128": "calculator-128.png" }
}

2 创建background.js 

chrome.app.runtime.onLaunched.addListener(function() {
  chrome.app.window.create('window.html', {
    'outerBounds': {
      'width': 400,
      'height': 500
    }
  });
});

3 创建window.html



  
  
  
    
Hello, world!
  

4 将calculator-16.png和calculator-128.png放到hello-world文件夹下面

5 启动应用,点击右上角菜单,选择更多工具-扩展程序,勾选开发者模式,点击加载已解压的扩展程序,选择hello-world文件之后扩展就安装到chrome了,点击启动即可查看到效果。

更多文档请参照官网