Skip to content

Commit

Permalink
Merge pull request #785 from mhelaiwa/2.x
Browse files Browse the repository at this point in the history
Add note to use inject for vue 3
  • Loading branch information
bakerkretzmar authored Nov 9, 2024
2 parents d379ade + ae5e26a commit 8970524
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,16 @@ Now you can use the `route()` function anywhere in your Vue components and templ
<a class="nav-link" :href="route('home')">Home</a>
```

With `<script setup>` in Vue 3 you can use `inject` to make the `route()` function available in your component script:

```vue
<script setup>
import { inject } from 'vue';
const route = inject('route');
</script>
```

If you are not using the `@routes` Blade directive, import Ziggy's configuration too and pass it to `.use()`:

```js
Expand Down

0 comments on commit 8970524

Please sign in to comment.