84669 person learning
152542 person learning
20005 person learning
5487 person learning
7821 person learning
359900 person learning
3350 person learning
180660 person learning
48569 person learning
18603 person learning
40936 person learning
1549 person learning
1183 person learning
32909 person learning
There are the following translations in the template:
<p> {{ $t('计数器:{n}', {n: counter}) }} </p>
where counter is just a number returned from the script and I want to apply a style to "n" (e.g. make it red).
How do I achieve this goal?
One way is to add HTML code directly in the translation. This will make the counter always appear in red:
translate:
counter: '计数器为:<span style="color: red">{n}</span>'
template:
<span v-html="$t('counter', {n: 22})" />
If you want the color to be more flexible, you can add additional parameters:
<span v-html="$t('counter', {n: 22, color: 'green'})" /> counter: '计数器为:<span style="color: {color}">{n}</span>'
One way is to add HTML code directly in the translation. This will make the counter always appear in red:
translate:
template:
If you want the color to be more flexible, you can add additional parameters: