@aboutdavid/easypwa 中文文档教程
EasyPWA
EasyPWA 让你轻松创建 PWA。 就像你所要做的就是添加:
var pwa = window.PWAinit();
window.easyPWA.inject(pwa, "/sw.js");
并将文件从 easypwa/sw.js 复制到你的服务器正在运行的文件夹中,并且你有一个 PWA。 当然,它具有默认品牌,但您可以更改这些值。 例如,要更改名称,只需修改“name”和“short_name”属性:
var pwa = window.easyPWA.init();
pwa.name = "Hello World";
pwa.short_name = "Hello World";
window.easyPWA.inject(pwa, "/sw.js");
要查看您可以配置的所有选项,请参阅 Web 应用程序清单上的 MDN 文档
Upgrading from v1 to v2:
v2 和更高版本中有一些 API/代码更改,使开发人员更容易使用它制作应用程序,并修复了一些浏览器上的一些问题。 因此,代码在 v2+ 上更加稳定
Installation:
npm install easypwa
Requiring the module:
<script src="/path/to/easypwa.js"></script>
API:
init()
:返回一个带有示例清单对象的 JSON 对象。 通常用于初始化 PWA。 用法:
window.easyPWA.init();
示例:
var pwa = window.easyPWA.init();
icon(url, size, ext)
:用于为清单的“图标”字段生成 JSON 对象。 url
是图标的 URL,size
是大小(widthxheigh)。
用法:
window.easyPWA.icon(
"url",
"widthxheight",
"png" // or file extention
) // {src: "url", sizes: "widthxheight", type: "image/png"}
示例:
pwa.icons = [
window.easyPWA.icon(
"https://cdn.glitch.com/70c8cfd0-7862-4692-9b6c-db66f49269bf%2Fandroid-chrome-192x192.png?v=1606418327912",
"192x192",
"png"
)
];
inject()
:这是注入/注册脚本以使 PWA 真正工作的函数。 用法:
window.easyPWA.inject(pwaObject, "/path/to/service-worker.js");
示例:
var pwa = window.easyPWA.init();
window.easyPWA.inject(pwa, "/sw.js");
Example:
示例位于index.html
EasyPWA
EasyPWA allows you to create a PWA easily. Like all you have to do is add:
var pwa = window.PWAinit();
window.easyPWA.inject(pwa, "/sw.js");
and copy the file from easypwa/sw.js to the folder your server is running and you have a PWA. Granted it has the default branding, but you can change those values. For example, to change the name, just modify the "name" and "short_name" attributes:
var pwa = window.easyPWA.init();
pwa.name = "Hello World";
pwa.short_name = "Hello World";
window.easyPWA.inject(pwa, "/sw.js");
To see all of the options you can configure, please see the MDN docs on Web app manifests
Upgrading from v1 to v2:
There is some API/code changes in v2 and higher to make it easier on devs making an application using this and fix some issues on a few browsers. So, the code is a lot more stable on v2+
Installation:
npm install easypwa
Requiring the module:
<script src="/path/to/easypwa.js"></script>
API:
init()
: Returns a JSON object with a sample manifest object. Normally used to initialize the PWA. Usage:
window.easyPWA.init();
Example:
var pwa = window.easyPWA.init();
icon(url, size, ext)
: Used to generate JSON objects for the "icons" field for the manifest. url
is the URL of the icon, size
is the size (widthxheigh).
Usage:
window.easyPWA.icon(
"url",
"widthxheight",
"png" // or file extention
) // {src: "url", sizes: "widthxheight", type: "image/png"}
Example:
pwa.icons = [
window.easyPWA.icon(
"https://cdn.glitch.com/70c8cfd0-7862-4692-9b6c-db66f49269bf%2Fandroid-chrome-192x192.png?v=1606418327912",
"192x192",
"png"
)
];
inject()
: This is the function that injects/registers the scripts to make the PWA auctally work. Usage:
window.easyPWA.inject(pwaObject, "/path/to/service-worker.js");
Example:
var pwa = window.easyPWA.init();
window.easyPWA.inject(pwa, "/sw.js");
Example:
The example is located in index.html
你可能也喜欢
- @0xproject/sol-resolver 中文文档教程
- @2toad/profanity 中文文档教程
- @42ndstudio/ckeditor5-build-inline-custom 中文文档教程
- @4a/koa-api-router 中文文档教程
- @8base-js-sdk/api 中文文档教程
- @__conn__/hyper-solarized-light 中文文档教程
- @abcnews/tiny-ducks 中文文档教程
- @abdulghani/react-promise-modal 中文文档教程
- @abhisekp/test-npm-app 中文文档教程
- @absolom/react-3dgallery 中文文档教程