I have code like this (JSFiddle)
<li v-for="(itemObjKey, catalog) in catalogs">this index : {{itemObjKey}}</li>
Output:
this index: 0
this index: 1
My question is:
To see the index for a specific table use SHOW INDEX: SHOW INDEX FROM yourtable; To see indexes for all tables within a specific schema you can use the STATISTICS table from INFORMATION_SCHEMA: SELECT DISTINCT TABLE_NAME, INDEX_NAME FROM INFORMATION_SCHEMA.
To find the position of an element in an array, you use the indexOf() method. This method returns the index of the first occurrence the element that you want to find, or -1 if the element is not found.
The index indicates the position of the element within the array (starting from 1) and is either a number or a field containing a number.
you can just add 1
<li v-for="(catalog, itemObjKey) in catalogs">this index : {{itemObjKey + 1}}</li>
to get the length of an array/objects
{{ catalogs.length }}
In case, your data is in the following structure, you get string as an index
items = { am:"Amharic", ar:"Arabic", az:"Azerbaijani", ba:"Bashkir", be:"Belarusian" }
In this case, you can use extra variable to get the index in number:
<ul> <li v-for="(item, key, index) in items"> {{ item }} - {{ key }} - {{ index }} </li> </ul>
Source: https://alligator.io/vuejs/iterating-v-for/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With