簡體   English   中英

Pug(Jade)模板中標簽的動態URL

[英]Dynamic url for a tag in Pug (Jade) template

我想動態更改URL文本。 這是我在Pug模板引擎中使用的代碼:

html
  head
    title=title
    <link rel="stylesheet" type="text/css" href="/css/style.css">
  body(style={'background-color': color })
    #content 
      .bigquestion=message
      | <div class='questionnumber'>
      a(href=`/question/`+ questionnumber) =questionnumber
      | / 
      =totalnumberofquestions
      | </div>

我得到以下內容:

<div class='questionnumber'><a href="/question/98">question =questionnumber</a>98/ 135</div>

我希望輸出是這樣的:

<div class='questionnumber'><a href="/question/98">question 98</a> / 135</div>

有什么方法可以在Pug模板引擎中使用動態文本作為URL嗎?

我只能在這里找到靜態文本示例。

請查看文檔中的此部分。

https://pugjs.org/language/interpolation.html

html
  head
    title=title
    <link rel="stylesheet" type="text/css" href="/css/style.css">
  body(style={'background-color': color })
    #content 
      .bigquestion=message
      | <div class='questionnumber'>
      a(href=`/question/`+ questionnumber) #{questionnumber}
      | / 
      =totalnumberofquestions
      | </div>

您需要在變量上使用插值,例如#{questionnumber}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM