ionic 3 将应用程序发布为 PWA(渐进式 Web 应用程序) [英] ionic 3 publish app as PWA (Progressive Web App)

查看:33
本文介绍了ionic 3 将应用程序发布为 PWA(渐进式 Web 应用程序)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将我的应用发布为 PWA,所以我所做的是

I want to publish my app as PWA so what i did is

将此脚本插入 index.html

insert this script to index.html

<!--script>
    if ('serviceWorker' in navigator) {
      navigator.serviceWorker.register('service-worker.js')
        .then(() => console.log('service worker installed'))
        .catch(err => console.log('Error', err));
    }
</script-->

然后安装

npm run ionic:build --prod 

它看起来像部署它,但我的问题是:

it looks like it deploy it but my questions are:

  1. 为了将应用发布为 PWA,我需要上传哪些文件到主机?
  2. 为什么当我在应用程序中更改某些内容并运行 ionic serve 时没有任何更改,而它仅在 WWW 文件夹的 index.html 中更改?为什么?(因为现在是 PWA??)

  1. what files I need to upload to host for publish the app as PWA?
  2. why when I change something in the app and run ionic serve nothing changed and it changed only in the index.html of the WWW folder? why?(because now it's PWA??)

当我打开 www 文件夹并运行 open index.html 时,当我按下打开警报对话框的按钮时,它不会打开它.为什么?

when I open www folder and I run open index.html when i press on button that open alert dialog it not open that. why?

推荐答案

运行

ionic cordova 平台添加浏览器

ionic 构建浏览器 --prod --release

然后转到 [project_folder]/platforms/browser/www 并在您的 http 服务器上复制内容.

Then go to [project_folder]/platforms/browser/www and copy the content at you http server.

这篇关于ionic 3 将应用程序发布为 PWA(渐进式 Web 应用程序)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆