This repository was archived by the owner on Nov 5, 2021. It is now read-only.
- Notifications
You must be signed in to change notification settings - Fork2
Wrapper for injecting laravel routes into your vue application
License
NotificationsYou must be signed in to change notification settings
samturrell/vue-laroute
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
Inject Laravel routes into your Vue application viaaaronlord/laroute. I actually recommend the alternative and more slim-lined version of this package fromAXN-Informatique/laravel-laroute.
Adding vue-laroute to your application is as simple as any other plugin:
importVuefrom'vue';importVueLaroutefrom'vue-laroute';importroutesfrom'../path/to/laroute.js';Vue.use(VueLaroute,{ routes,accessor:'$routes',// Optional: the global variable for accessing the router});newVue({el:'#app',});
You can now access your global accessor ($routes
by default) in any component viathis.$routes
, for example:
<template><div><h1>You can access it in your template</h1><nav><ul><li><a :href="$routes.route('home')">Home</a></li><li><a :href="$routes.route('products')">Home</a><ul><li><a :href="$routes.route('products.show', { id: 1 })">Product1</a> </li><li><a :href="$routes.route('products.show', { id: 123 })">Product123</a> </li></ul></li></ul> </nav><button @click.prevent="purchaseProduct(123)">Purchase product</button> </div></template><script> export default{methods:{purchaseProduct(id){this.$http.post(this.$routes.route('products.purchase',{id:id})).then((response)=>{// Handler});},},}</script>
Details changes for each release are documented in theCHANGELOG.md.
Please make sure to read theIssue Reporting Checklist before opening an issue. Issues not conforming to the guidelines may be closed immediately.
Please make sure to read theContributing Guide before making a pull request.