Node.js HTML样式属性中的EJS变量

Node.js HTML样式属性中的EJS变量,node.js,express,ejs,Node.js,Express,Ejs,我正在尝试将Vrable传入此div的style属性: <div class="progress progress-sm"> <div class="progress-bar bg-success" aria-valuenow="<%=Math.round((resp.length / 14) * 100) %>" aria-valuemin="0" aria-valuema

我正在尝试将Vrable传入此div的style属性:

<div class="progress progress-sm">
      <div class="progress-bar bg-success" aria-valuenow="<%=Math.round((resp.length / 14) * 100) %>" aria-valuemin="0" aria-valuemax="100" style="width: <%=Math.round((resp.length / 14) * 100) %>%;"><span class="sr-only"><%=Math.round((resp.length / 14) * 100) %>%</span></div>
</div>

%

但不幸的是,它说的是预期的属性值,所以我假设我不能在这里传递变量。这有什么办法吗?我可以在其他地方使用相同的变量,所以不是这样。

我找到的解决方案是在底部添加一些javascript,如下所示:

   <script>
    document.getElementById('prog').style.setProperty('width', '<%=Math.round((resp.length / 14) * 100) %>%')
</script>

document.getElementById('prog').style.setProperty('width','%'))