javascript Jade 模板:使图像成为链接
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/30195563/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Jade Templates: Make an image a link
提问by Giancarlo Manuel Guerra Salvá
So in HTML i'd do something like this:
所以在 HTML 中我会做这样的事情:
<a href="www.something.com">
<img src="my/machine">
</a>
to make the image into a link. But I want to do the same for Jade. I was reading through the docs herebut nothing relating to what I want. Help please? Thanks very much in advance.
回答by technophobia
What you're doing is nesting elements. Nesting just requires new lines and a tab per nest level.
您正在做的是嵌套元素。嵌套只需要新行和每个嵌套级别的选项卡。
Jade:
玉:
a(href='www.something.com')
img(src='my/machine')
回答by Sheev
Use img(src= someExpr)
where someExpr will be evaluated to the path to your image.
使用img(src= someExpr)
where someExpr 将被评估为您的图像的路径。