i18n 支持参数的写法
背景:1、因为中英文语序的问题,很多文字不能直接通过中式的拼接直接完成,例如‘还可以输入**个字’。2、在完成输入参数后,参数的样式是需要定制样式的,但怎么实现呢?解决方法:1、在国际化文件中输入'tip': '还可以输入{0}字'2、在vue中的script使用this.$t(`main.common.tip`, [this.maxInputLength - this.inputValue.le
·
背景:
1、因为中英文语序的问题,很多文字不能直接通过中式的拼接直接完成,例如‘还可以输入**个字’。
2、在完成输入参数后,参数的样式是需要定制样式的,但怎么实现呢?
解决方法:
1、在国际化文件中输入
'tip': '还可以输入{0}字'
2、在vue中的script使用
this.$t(`main.common.tip`, [this.maxInputLength - this.inputValue.length])
3、定制样式方式
<i18n path="main.common.tip" tag="span">
<span class="length-tip">{{[this.maxInputLength - this.inputValue.length}}</span>
</i18n>
效果:
更多推荐
已为社区贡献1条内容
所有评论(0)