javascript - Error reporting when introducing js into ejs
大家讲道理
大家讲道理 2017-05-19 10:19:17
0
2
391


How to solve this error

I want to display alert() in ejs, similar to this
http://stackoverflow.com/ques...

大家讲道理
大家讲道理

光阴似箭催人老,日月如移越少年。

reply all(2)
我想大声告诉你

Remove the <%= if (msg){ %>= in the first line.

  • <% JavaScript 控制代码,不输出 %>

  • <%= 输出值 (HTML escaped) %>

  • <%- 输出值,原样输出 %>

阿神
<body>

<% if (msg){ %>
<p><%= msg %></p>
<% } %>

<input id="msg" type="hidden" value="<%= msg %>">

<script>

  var msg = document.querySelector('#msg').value;
  console.log(msg);


  alert(<%= msg%>);
  
  var msg1 = <%= msg%>;
  console.log(msg1);
  
</script>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template