ios提供了PWA支持,通过manifest.json来配置具体属性,包含应用名称,应用图标等。具体示例如下:

1. 在h5 首页中加入 manifest

<!DOCTYPE html>
<html lang="en" class="no-js no-webp">
<head>

    <title>roots</title>
    <link rel="manifest" href="/site.webmanifest">

2. 首页同级目录中添加 site.webmanifest文件,文件内容如下:

{
  "background_color": "#ffffff",
  "description": "ddd.",
  "display": "standalone",
  "icons": [
    {
        "src": "icon/icon192.png",
        "sizes": "192x192",
        "type": "image/png",
        "purpose": "any"
    },
    {
        "src": "icon/icon196.png",
        "sizes": "196x196",
        "type": "image/png",
        "purpose": "maskable"
    },
    {
        "src": "icon/icon256.png",
        "sizes": "256x256",
        "type": "image/png",
        "purpose": "any"
    },
    {
        "src": "icon/icon512.png",
        "sizes": "512x512",
        "type": "image/png",
        "purpose": "any"
    }
],
  "name": "ddd",
  "prefer_related_applications": false,
  "scope": "/",
  "short_name": "name",
  "start_url": "/?source=pwa",
  "theme_color": "#ffffff"
}

Logo

华为开发者空间,是为全球开发者打造的专属开发空间,汇聚了华为优质开发资源及工具,致力于让每一位开发者拥有一台云主机,基于华为根生态开发、创新。

更多推荐