Chrome离线应用开发方法详解

目录

Chrome离线应用开发方法详解

假如在文件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

<!DOCTYPE html>
<html>
  <head>
  </head>
  <body>
    <div>Hello, world!</div>
  </body>
</html>

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

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

更多文档请参照 官网

打赏一个呗

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码支持
扫码打赏,你说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦