0

In a Vue2 component i have a language array witch have all translated texts

"translated": {
    "oneText": "Text one",
    "twoText": "Text two"
}

I need to show the language text based in a received value from item.number the value can be one, two...

I try this but in the case item.number is one this return me translated.oneText value not Text one

<span>{{ 'translated.' + item.number + 'Text' }}</span>

And this obviously return an error when runs...

<span>{{ translated. + item.number + Text }}</span>

1 Answer 1

1

Have you tried

{{ translated[item.number + "Text"] }}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.