Problems with making route call, console error. #486
-
I just discovered this library and I am trying to implement it, I tried to follow the tutorial installed through composer in laravel 8, I made the mention in webpack.mix.js and in the app.js file but when I navigate in the vue component the console throws me the following error The thing is that when I do npm run dev I don't get any error, how can I fix it or make it work? Versions
App.js
Component method
Layout blade
webpack.mix.js
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Ok a couple things—first, because you're using the If you do choose to load Ziggy as a Vue plugin, you have to import - import { route } from 'ziggy';
+ import { ZiggyVue } from 'ziggy';
- Vue.use(route,Ziggy);
+ Vue.use(ZiggyVue, Ziggy); You may also need to change your alias to Then, You're also importing Vue twice which could be causing other problems. Let me know if you get it working! |
Beta Was this translation helpful? Give feedback.
Ok a couple things—first, because you're using the
@routes
Blade directive, you can just remove all the Ziggy setup from yourapp.js
andwebpack.mix.js
if you want to. Theroute()
helper is already available globally.If you do choose to load Ziggy as a Vue plugin, you have to import
ZiggyVue
, notroute
:You may also need to change your alias to
...ziggy/dist/vue
, or import ZiggyVue from'ziggy/vue
.Then,
route
will be accessible as a method on all your components. Inside templates you can just callroute()
, but inside the<script>
tags of the Vue component, like in yo…