我有一个 jade 模板,我想将它作为脚本 src 传入一个变量,因为在不同的路由上脚本会发生变化。我如何在 Jade 和 Express 中执行此操作?
doctype html
html
body
#app!= html
script(src={bundle})
在脚本 src 中传入我想要的 bundle
变量
var html = React.renderToString(node)
var bundle = '/public/js/bundle.js'
res.render('layout', { html: html, bundle: bundle })
最佳答案
看起来我可以自己回答这个问题,在这个 question 的帮助下
如其所述,#
用于转义数据,!
用于原始数据。
doctype html
html
body
#app!= html
script(src='#{bundle}')
关于javascript - 如何将脚本 src 传递给 jade 模板,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30585931/