ReactJS - 字符串中的插值而不是渲染

时间:2016-06-15 00:08:55

标签: html reactjs

我必须渲染一个很长的令牌。我不想渲染它,而是让下面的代码旁边有一个剪贴板图标。

<p>Get your ${ID_TOKEN} here!</p>

如何逃避插值? React一直试图渲染它,就像我试图渲染一个变量一样。

我已经尝试过分配一个等于插值字符串的变量。

const token = "${USER_TOKEN}"

1 个答案:

答案 0 :(得分:2)

假设你使用的是ES6而你的意思是逐字渲染'$ {ID_TOKEN}'你应该可以做到:

import java.util.Random;

public class Test {
    public static void main(String[] args) {
        Random rand = new Random();
        int x = 0;
        int rock = 0;
        int paper = 0;
        int scissors = 0;

        for (int i = 0; i < 100; i++) {
            x = rand.nextInt(3);
            if (x == 1) {
                rock += 1;
            } else if (x == 2) {
                paper += 1;
            } else {
                scissors += 1;
            }

        }

        System.out.println("Rock = " + rock + "\nPaper = " + paper + "\nScissors = " + scissors);
    }
}

超级简单DEMO

相关问题