如何使用线性渐变中的颜色十六进制代码? colors.js buttonH1.jsx

问题描述

我将彩色十六进制代码放入数组中,我想在其中使用数组的名称,而不是使用线性渐变中的彩色十六进制代码。(我使用ReactJs库)

colors.js

ResultSet chaserResults = Litesql.onQuery("SELECT count(*),id,name,geburt,geschlecht,speed,speedf,strength,strengthf," +
                "val3,val3f,val4,val4f,val5,val5f,position FROM player WHERE position = 'Chaser' AND teamid = " + teamid);
        setchaser = new Chaser[chaserResults.getInt("count(*)")];
        int i = 0;
        while(chaserResults.next()){
            setchaser[i] = new Chaser(chaserResults.getInt("id"),chaserResults.getString("name"),chaserResults.getInt("geburt"),teamResults.getInt("id"),chaserResults.getInt("geschlecht"),chaserResults.getInt("speed"),chaserResults.getInt("speedf"),chaserResults.getInt("strength"),chaserResults.getInt("strengthf"),chaserResults.getInt("val3"),chaserResults.getInt("val3f"),chaserResults.getInt("val4"),chaserResults.getInt("val4f"),chaserResults.getInt("val5"),chaserResults.getInt("val5f"),chaserResults.getString("position"));
            i++;
            System.out.println(i);
        }

buttonH1.jsx

export const primaryGradient = ["#B16E2A","#E9AD57"]//Gold

解决方法

您可以将template strings与es6一起使用。

所以: backgroundImage: `linear-gradient(${primaryGradient[0]},${primaryGradient[1]})`,