我刚接触jade,并被这个问题卡住了。我想我已经尝试了从StackOverflow帖子开始的所有方法,但仍然一无所获。
我尝试过的东西
button(type='button' class=' c-btn-blue c-btn-circle c-btn-uppercase' value="Read More" onclick='gotoBlog( #{val.link} )')
错误
1:8 Uncaught SyntaxError: Invalid or unexpected token
将其更改为!{val.link}
错误
Uncaught SyntaxError: Unexpected token .
将其更改为"!{val.link}"
和"#{val.link}"
可以理解地给出字符串。顺便说一下,val.link是一个字符串
只是给val.link说Uncaught ReferenceError: val is not defined
我现在别无选择了。我们将非常感谢您的帮助。
谢谢
发布于 2016-08-27 04:52:03
向html元素添加属性时,您已经在pug的作用域中,所以您可以像使用常规js变量一样使用pug变量。
button(type='button' class=' c-btn-blue c-btn-circle c-btn-uppercase' value="Read More" onclick='gotoBlog(' + val.link + ')')
发布于 2018-11-21 05:24:49
我只使用了下面的代码,它对我很有效(带有pre和pos引号)
button(type='button', onclick='someFunction("'+ yourObject.id +'")' ) PressMe
发布于 2016-11-28 02:07:46
你只需要把onclick="myfunction(#{varible.atributo})“
下面是一个示例:
table
thead
tr
th #ID
th Description
th Actions
tbody
each item, i in itemlist
tr
th(scope='row') #{item.id}
td #{item.description}
td
button(onclick="editItem(#{item.id})", title="Edit")
| Edit
https://stackoverflow.com/questions/39160264
复制相似问题