【问题标题】:Template literals inside of quotation marks引号内的模板文字
【发布时间】:2021-01-31 17:57:08
【问题描述】:

我怎样才能写出它才能工作?

document.getElementById("td-`${i}`")

【问题讨论】:

    标签: javascript syntax template-literals quotation-marks


    【解决方案1】:

    您应该使用模板文字代替引用的字符串,而不是在其中:

    document.getElementById(`td-${i}`)
    // Here ----------------^-------^
    

    【讨论】:

      猜你喜欢
      • 2016-06-18
      • 1970-01-01
      • 1970-01-01
      • 2023-03-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-10-21
      • 2020-05-26
      相关资源
      最近更新 更多