0

Issue:

I have a laravel 9 app builded with vue3 , inertia-laravel , inertiajs and laravel-vite , it works perfetct on PC but when I try to open it in mobile device It show a blank page without any console log.

NB : when I toggle device toolbar to mobile in a navigator it works correctly but in real mobile no ( I tested on different navigators)

I can't fix this issue come from inertiajs\inertia-vue3 or inertiajs/inertia-laravel
When I render a blade view it works, just when I render inertia object

Versions:

  • inertiajs/inertia-laravel version: 0.6.3
  • @inertiajs/inertia version: 0.11.0
  • @inertiajs/inertia-vue3 version: 0.6.0

Codes:

web.php:

Route::get('/', function() {
        return Inertia::render('WelcomeView');
    });

app.js

import './bootstrap';

import '../css/main.css'

import { createPinia } from 'pinia'
import { useStyleStore } from '@/Stores/style.js'

import { darkModeKey } from '@/config.js'

import { createApp, h } from 'vue'
import { createInertiaApp } from '@inertiajs/inertia-vue3'
import { InertiaProgress } from '@inertiajs/progress'
import { resolvePageComponent } from 'laravel-vite-plugin/inertia-helpers'
import { ZiggyVue } from '../../vendor/tightenco/ziggy/dist/vue.m'
import Notifications from 'notiwind'
import * as ConfirmDialog from 'vuejs-confirm-dialog'

const appName = window.document.getElementsByTagName('title')[0]?.innerText || 'Laravel'

const pinia = createPinia()

createInertiaApp({
    title: (title) => `${title} - ${appName}`,
    resolve: (name) => resolvePageComponent(`./Pages/${name}.vue`, import.meta.glob('./Pages/**/*.vue')),
    setup({ el, app, props, plugin }) {
        return createApp({ render: () => h(app, props) })
            .use(plugin)
            .use(pinia)
            .use(Notifications)
            .use(ConfirmDialog)
            .use(ZiggyVue, Ziggy)
            .mount(el);
    },
});

InertiaProgress.init({ 
        color: '#5136a8',
        showSpinner:true 
    })

const styleStore = useStyleStore(pinia)

/* App style */
//styleStore.setStyle(localStorage[styleKey] ?? 'basic')
styleStore.setStyle()
/* Dark mode */
if ((!localStorage[darkModeKey] && window.matchMedia('(prefers-color-scheme: dark)').matches) || localStorage[darkModeKey] === '1') {
  styleStore.setDarkMode(true)
}

WelcomeVue.vue (under pages folder) :

<template>
<div>
   hellow world
</div>
</template>

and app.blade.php :

<!DOCTYPE html>
<html lang="{{ str_replace('_', '-', app()->getLocale()) }}">
    <head>
        <meta charset="utf-8">
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <meta name="csrf-token" content="{!! csrf_token() !!}" />
        <title inertia>{{ config('app.name', 'Laravel') }}</title>

        <!-- Fonts -->
      
        <!-- Scripts -->
        @routes
        @vite('resources/js/app.js')
        @inertiaHead
    </head>
    <body class="font-sans antialiased">
        @inertia
    </body>    
</html>
  • Is this issue being caused on an iPhone device by any chance? Also check this answer out it may help you https://stackoverflow.com/questions/38125480/vuejs-doesnt-work-on-mobile – dz0nika Sep 30 '22 at 09:42
  • @dz0nika yess ! – MAHA OUEGHLANI Sep 30 '22 at 09:46
  • I knew it, this is a common iOS issue, so here is the one answer that helped me https://laracasts.com/discuss/channels/vue/works-on-desktop-but-not-mobile also make sure you don't have any v-bind because they are not mobile friendly for some reason. Cheers – dz0nika Sep 30 '22 at 09:52
  • @dz0nika thank you no I knew the origin issue but this links can't help me, anyway thank's, I will search .. – MAHA OUEGHLANI Sep 30 '22 at 10:11

0 Answers0