Documentation is missing the requirement of `vendor/tightenco/ziggy/src/js/route.js`
See original GitHub issueExpected Behavior
Documentation should explain that the route.js
file needs to be imported from vendor/tightenco/ziggy/src/js/route.js
when using the ziggy:generate
artisan command.
Current Behavior
Not documented.
I’ve put together an example for anyone that uses Laravel Mix and Vue (probably a lot of people who want to use Ziggy!)
Issue Analytics
- State:
- Created 4 years ago
- Comments:21 (1 by maintainers)
Top Results From Across the Web
Type 'Document' is missing the following properties from type
The problem is I am having this typescript error that says "Type 'Document' is missing the following properties from type 'SavedUser': firstName ...
Read more >[BUG] Missing required argument #1 #681 - npm/cli - GitHub
My solution works for me ! Install node.js 及 npm. sudo apt install nodejs sudo apt install npm.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
When using
Vue.mixin()
, you are essentially adding something to every component definition, so the following snippet:adds a
route()
method to every component (accessible withthis.route('route.name.here')
.For your example, you don’t need to assign
route
at all in thedata() { ... }
portion of your component. You can fix yourimportUser()
method by simply usingaxios.post(this.route('users.store'))
.To use
route()
outside Vue components:There are times where I need to use the route method outside of Vue components. For this, i use the following solution:
Make a separate
route.js
file that you can import wherever you need it:Then you can import it into
app.js
to set up the global mixin:Or in any other module / js file e.g. a VueX store:
Depending on your Laravel version, you may need to change the path of the
ziggy:generate
command as it defaults to the ‘legacy’resources/assets/js/
directory. Laravel >=5.8 (I think) usesresources/js/
instead.I’ve just done a fresh Laravel install and these are the exact steps taken to get Ziggy to work with Vue:
Set up in terminal:
webpack.mix.js
routes/web.php
Run Ziggy
resources/js/app.js
** resources/js/components/ExampleComponent.vue **
Add built assets to your blade layout
Add Vue component to your blade view
Build assets