I'm creating a dropdown component with Vue 3 and importing it inside my Laravel 8 project. The dropdown works perfectly and looping over the categories in database as expected.
The issue is that i want when i click on a category it routes me to '/categories/$category->slug' which is defined in Laravel routes already and works if i enter it manually. But i can't find a way to say $category->slug in vue component.
I tried anchor tags and inside the href '/categories/{{category.slug}}' but it doesn't work. All i need is to have an anchor tag or router-link that directs me to '/categories/$category->slug'
Okay i solved it and it was pretty simple!
I simply added to data() the below code
categoryRoute: "/categories/",
Then adjusted the href like so
:href="this.categoryRoute + category.slug"
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.