G
G
grande2k2021-11-15 23:10:26
Vue.js
grande2k, 2021-11-15 23:10:26

How to give the exact(vue-router library) attribute to the first element of a Vue array?

Hello, I want to display the navigation in the header by iterating through the array using v-for, but I ran into a problem that I need to give the exact attribute (which is responsible for the so-called "home page") to the first element of this list, I
tried using :exact="{'' : index === 0}" - WORKS, but the error in the console is "[Vue warn]: Invalid prop: type check failed for prop "exact. Expected Boolean, got Object"

<li v-for="(item, index) in navItems" :key="index" @click="burgerMenu"><router-link :to="item.to" :exact="{'' : index === 0}">{{item.name}}</router-link></li>
navItems: [
        {name: 'Home', to: {name: 'home',}},
        {name: 'About', to: {name: 'about'}},
        {name: 'Portfolio', to: {name: 'portfolio'}},
        {name: 'Contacts', to: {name: 'contacts'}},
      ]

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Aetae, 2021-11-15
@grande2k

The error says it all:

Expected Boolean, got Object

If you don't know English - use google translate:
I'm waiting for Boolean, and you give me Object

:exact="index === 0"

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question