【问题标题】:I want to create an html hyperlink by concating one of the variables from postgresql我想通过连接来自 postgresql 的变量之一来创建一个 html 超链接
【发布时间】:2022-07-21 22:45:57
【问题描述】:

我是 html 新手 我在我的 html 中有从 postgresql 返回的值,这些值显示在表格中 我想连接其中一个值以生成超链接。怎么做 例如 todo[3]="UX123456" 的值 我想生成一个超链接文件://localhost/C:/UX123456/UX123456.txt 我通过以下代码得到的是 file:///C:/ 。 请告诉我如何达到预期的效果

{% for todo in todos %}
        <tr style="font-size:13px;height:30px">
            <td style="text-align:center">{{ todo[0] }}</td>
            <td style="text-align:center">{{ todo[1]}}</td>
             ...
              ...
          **<td style="text-align:center"> <a href="file://localhost/C:/"+{{ todo[3]}}+"/"{{todo[3]}}+".txt">{{ todo[3]}}</a></td>**
           ....
           ...
    </tr>
{% endfor %}

我期待

【问题讨论】:

    标签: html concatenation


    【解决方案1】:

    我认为您使用的是模板语言,这不是纯 HTML。

    但是您可以尝试使用模板文字:只需将反引号 (`) 放在您的字符串周围,然后像这样嵌入您的数据 ${variable}

    文档:https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-05-19
      • 2016-01-31
      • 2020-05-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多