【问题标题】:Colors.js: Proper syntax for adding a color to a variable (string)?Colors.js:向变量(字符串)添加颜色的正确语法?
【发布时间】:2011-12-29 19:17:33
【问题描述】:

除了我的静态消息(显示得很好)之外,如何在这个 console.log 中将名为“port”的变量设为绿色?

console.log('Express app started on port '.green + port);

我没有看到任何关于在文档中为变量添加颜色的内容,当然,如果我只是将 .green 添加到端口,它会查找未定义的端口 var 的 .green 元素。

使用:https://github.com/Marak/colors.js

【问题讨论】:

    标签: node.js colors express


    【解决方案1】:

    colors.js修改字符串对象--试试

    port.toString().green
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-11-16
      • 2020-11-19
      • 1970-01-01
      • 2015-01-28
      • 2012-05-24
      相关资源
      最近更新 更多