Join the Stack Overflow Community
Stack Overflow is a community of 6.6 million programmers, just like you, helping each other.
Join them; it only takes a minute:
Sign up
class="tab-title" 
v-on:click="tab" 
v-for="(tabTitle,index) in tabTitleList"
:id="index"

I found this example in an vue community, but in my situation, I want my "id" has a prefix, not just a number.

That is to say, if the index is 1, I want <span id='sp_1'></span> instead of <span id='1'></span>.

share|improve this question
up vote 2 down vote accepted

You can just do, code should be self explanatory:

<div v-for="(tabTitle, index) in tabTitleList">
    <span :id="'sp_' + index"> {{tabTitle}} </span>
</div>

Documentation link.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.