简体   繁体   English

在React JS中用颜色标记一行

[英]Mark a line with a color in React js

I would like to mark a certain line in my React component in green. 我想在我的React组件中以绿色标记一行。

After searching for a way to do that, this is what I wrote: 在寻找实现方法之后,这是我写的:

     var transferDateElemet =  <tr>
                  <td>Date of transfer to organization </td>
                  <td style={{color: green,background: '#00CC00'}}>
                             {transferDate.getUTCDate() + "/" + (transferDate.getUTCMonth() +1 ) + "/" + transferDate.getUTCFullYear()}{transferDateExpected}
                  </td>
              </tr>;

Of course, it is written inside render(). 当然,它是在render()中编写的。

I would like to get a suggestion of how to make it work. 我想对如何使其工作提出建议。 Also, if I did not supply enough details please let me know. 另外,如果我没有提供足够的详细信息,请告诉我。

*This is the error I get: *这是我得到的错误:

Failed to compile.

EBUSY: resource busy or locked, unlink 'C:\Users\***\***\***\***\***\***\static\media\logo.ee7cd8ed.svg'


npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! my-app@0.1.0 build: `react-scripts build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the my-app@0.1.0 build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

There is no need to add div in tr element.Try this: 无需在tr元素中添加div。尝试以下操作:

<td style={{color: green,background: '#00CC00'}}>
{transferDate.getUTCDate() + "/" + (transferDate.getUTCMonth() +1 ) + "/" + transferDate.getUTCFullYear()}{transferDateExpected}

Edit: For your problem, there are many reasons for this, so here are some options for you to try. 编辑:对于您的问题,有很多原因,所以这里有一些选项供您尝试。

  1. run npm cache clean and npm install 运行npm cache cleannpm install
  2. close editor software and open it again 关闭编辑器软件,然后再次打开
  3. if you are using windows, close node.js serve in back terminal and close the window defender 如果您使用的是Windows,请关闭node.js在后端的服务,并关闭窗口防御程序

The color property makes the text color green. color属性使文本颜色变为绿色。 Is the text not changing to green? 文字没有变为绿色吗? If not try using hex code and see if it works 如果没有尝试使用十六进制代码,看看是否可行

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM