manifest.json
文件:
{ "name": "Our app","description": "Our app description","short_name": "our-app","icons": [ { "src": "/content/favicons/android-chrome-36x36.png","sizes": "36x36","type": "image/png","density": 0.75 },{ "src": "/content/favicons/android-chrome-48x48.png","sizes": "48x48","density": 1 },{ "src": "/content/favicons/android-chrome-72x72.png","sizes": "72x72","density": 1.5 },{ "src": "/content/favicons/android-chrome-96x96.png","sizes": "96x96","density": 2 },{ "src": "/content/favicons/android-chrome-144x144.png","sizes": "144x144","density": 3 },{ "src": "/content/favicons/android-chrome-192x192.png","sizes": "192x192","density": 4 } ] }
连同它位于的图标:/content/favicons/manifest.json.所以我们这样引用它:< link rel =“manifest”href =“/ content / favicons / manifest.json”>
我对manifest.json文件进行了大量研究,并且网上的所有内容仅解释了当所有文件都在根文件夹中时如何处理它,这是我们不想要的.我们需要保持干净,所以我们为所有与favicon相关的东西引入了一个新文件夹.
问题是,如果允许这样做,并且src路径(例如“src”:“/ content / fabicons / android-chrome-48×48.png”)需要是相对的还是绝对的.那么src路径在这个设置中应该是什么?
解决方法
假设您有以下文件:
> /content/favicon/android-chrome-192×192.png
> /content/favicon/manifest.json,引用android-chrome-192×192.png
> /index.html,引用manifest.json与< link rel =“manifest”href =“/ content / favicon / manifest.json”>
然后manifest.json的相应src属性可以设置为:
> /content/favicon/android-chrome-192×192.png(即绝对路径).这是你可以用favicon compatibility test of RFG测试的(完全披露:我是这个网站的作者).> android-chrome-192×192.png(即相对路径).我刚刚使用Android Chrome 51对此进行了测试.但是,应该再次检查此选项,因为更多浏览器支持Web应用清单.