我有VUEJS的PWA,我需要帮助使此代码在iPhone上运行。在Android上,它可以完美运行。如果该人尚未安装该应用程序,则该按钮出现,但是如果该人已经安装了该应用程序,则该按钮消失。 IOS没有提示,但是我想添加一个按钮,单击该按钮时,会将用户带到pwa的安装中。

data() {
        return {
            installBtn: 'block',
            installer: undefined,
},


created(){
        const self = this;

       let installPrompt;
       window.addEventListener("beforeinstallprompt", e => {
           e.preventDefault();
           installPrompt = e;
           this.installBtn = "block";

       });

       this.installer = () => {
           this.installBtn = "none";
           installPrompt.prompt();
           installPrompt.userChoice.then(result => {
               if(result.outcome === "accepted") {
                   console.log("User Accepted");
               } else {
                   console.log("User denied");
               }
               installPrompt = null;
           });
       };
},

最佳答案

我认为iOS Safari当前不支持网络应用安装横幅。见https://stackoverflow.com/a/51160938/4472488

关于ios - 使用Vuejs在iOS上进行PWA安装promt,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/59757837/

10-09 20:07