No reason to use the Vue plugin if you're using @routes blade directive? #656
-
Is there any reason to use the Ziggy Vue plugin if you're using the The documentation says:
... but it seems that you don't need to use the Vue plugin at all in this scenario since Am I missing something here, or should the docs be updates to say that you don't need to use the Vue plugin at all with Blade |
Beta Was this translation helpful? Give feedback.
Replies: 6 comments
-
You're not missing anything, it is possible to use the global |
Beta Was this translation helpful? Give feedback.
-
That's the thing, though. The IDE (JetBrains stuff, at least) doesn't know about We do use the composition api with Vue 3 and We use Jetstream to start a lot of projects, so the config looks like this: https://github.com/laravel/jetstream/blob/3.x/stubs/inertia/resources/js/app.js |
Beta Was this translation helpful? Give feedback.
-
To follow up on this, our current strategy for making everything work is to use the Jetstream |
Beta Was this translation helpful? Give feedback.
-
More info about this here. What brought this up is looking at the implementation in Laravel Jetstream. This implementation uses the plugin, but then all the components are using the Vue 3 composition api with Should this very popular implementation be updated or corrected? |
Beta Was this translation helpful? Give feedback.
-
To use the
I don't know about JetBrains specifically and this depends a lot on where exactly you're talking about. Inside a component
If you don't care about intellisense you don't need to
No, the plugin is making it possible to use |
Beta Was this translation helpful? Give feedback.
-
Actually, this makes the intellisense work correctly with typescript, since it's mapped to the type import rather than the import from ziggy directly (this is probably a weird implementation). But yeah, my understanding was that we are actually using the window-level function from the blade directive and that this import was just for typing that global function. That's good to have cleared up. Thanks! I think the problem with I think the big confusing thing was that in Laravel Jetstream it implements the Vue plugin in the app setup, but then never does any Thank you for taking the time to reply to all of this and provide a thorough explanation of how the bits are working together. |
Beta Was this translation helpful? Give feedback.
To use the
route()
function inside your Vue component<template>
tags you need the Vue plugin (or you need to recreate its functionality yourself), because the templates are compiled and can't access the global browser scope.I don't know about JetBrains specifically and this depends a lot on where exactly you're talking about. Inside a component
<template>
, using the Vue plugin, the IDE should be able to tell that theroute()
function exists. In a component<script>
you have toconst route = inject('route');
, althoug…