在AlpineJS的`x-text`中添加字符。

huangapple go评论69阅读模式
英文:

Add character inside AlpineJS x-text

问题

在AlpineJS中,我有以下的代码:

<span class="value" x-text="calculate"></span>

函数calculate返回一个数字。

如何在x-text后面添加字符 "€" 到数字后面?

英文:

Using AlpineJS I have the following code:

&lt;span class=&quot;value&quot; x-text=&quot;calculate&quot;&gt;&lt;/span&gt;

The function calculate returns a number.

How to inside the x-text add the character "€" after the number?

答案1

得分: 2

<span class="value" x-text="calculate() + '€'"></span>
英文:

This should work:

&lt;span class=&quot;value&quot; x-text=&quot;calculate() + &#39;€&#39;&quot;&gt;&lt;/span&gt;

答案2

得分: 0

英文:

you can do the following:

&lt;span class=&quot;value&quot; x-text=&quot;&#39;€&#39; + calculate&quot;&gt;&lt;/span&gt;

huangapple
  • 本文由 发表于 2023年8月5日 00:46:40
  • 转载请务必保留本文链接:https://go.coder-hub.com/76837817.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定