[英]Interpolation in React is not working this way can anybody please help me in this regards?
我正在嘗試插值,這樣
var sample = "test";
var result = 'this is just a ${sample}';
alert(result);
它不起作用,它只是在發出警報,這只是一個 ${sample},有人可以幫我解決這個問題嗎? 謝謝
您需要使用反引號而不是引號(鍵盤上1
的左側)
var result = `this is just a ${sample}`;
使用 ES5,它將是
var sample = "test";
var result = 'this is just a '+sample;
alert(result);
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.