I built 2 PWA based on Vue (with Vue UI templates, with router and PWA already set up) but I get on both the same issue: after I add to Homescreen on device, when I open it from the app icon, the router viez doesn't show up and stays blank until I click on a router link. I don't understand why.
Example of one of them, my portfolio:
URL Link
GitHub Link
Some parts of files here that I think related to the issue:
router.js:
export default new Router({
mode: 'history',
base: 'index.html',
routes: [
{
path: '/',
name: 'home',
component: Home
}
]
})
firebase.json:
"rewrites": [
{
"source": "**",
"destination": "/index.html"
}
]
To have the Vue-Router routes be rendered you will need to pass the <router-view> tag inside a Vue component. You could also access the routes from an <a> tag, but this will trigger a page re-render, to avoid this behavior you could use router-link with the to property instead of a href .
Vue CLI offers a convenient PWA plugin, and, even better, it can be added to an existing or new project.
Edit: Checkout @webmint answer below, probably solve problem im better and clean way.
Orginal Post:
I solved my problem adding an alias to start page in routes (in my case "Login")
in manifest.json:
{
...
"start_url": "index.html",
...
}
in router config:
let router = new Router({
...
routes: [
{ path: '/index.html',
component: Login,
alias: '/'
},
{
path: '/',
name: 'login',
component: Login
},
...
Had same issue. Turns out that solution is quite simple. You have to add/change this in manifest.json
"start_url": "/",
"scope": "/"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With