Vue/Inertija/Vite don't work with @routes? #688
-
I want to use Ziggy with Laravel / Inertia / Vue / VIte This is what I did:
Inside my Vue Component I use the route helper like this:
This fails with Uncaught (in promise) TypeError: _ctx.route is not a function There is some explanation how to setup frameworks without @routes, but it also states at https://github.com/tighten/ziggy#javascript-frameworks that most don't need this. Is this not true for vite/vue/inertija? Do I have to follow the instructions there? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
I managed to get it working using the https://github.com/tighten/ziggy#javascript-frameworks, but maybe if vite, vue, inertija don't work with @routes, a note would be great in the docs. Can someone confirm this is not supposed to work? |
Beta Was this translation helpful? Give feedback.
-
Inertia and Vue work fine with Inside the I agree that note in the docs is a bit misleading, I'll tweak that wording. |
Beta Was this translation helpful? Give feedback.
Inertia and Vue work fine with
@routes
. Making any global JavaScript function/variable available inside the<template>
of Vue single-file components, whether that'sroute()
orconsole.log()
or anything else, requires some additional setup. You can either do that setup yourself or you can use Ziggy's Vue plugin, which does it for you.Inside the
<script>
of your components, and anywhere else in your JS code,route()
should be available with the setup you showed above.I agree that note in the docs is a bit misleading, I'll tweak that wording.