static javascript not rendering in jade (with express/node.js)

前端 未结 4 531
误落风尘
误落风尘 2021-01-19 14:43

I hope you are well.

I\'m suddenly unable to render any external javascript in jade templates! To get to the bottom of things, I stripped it down to the bare minimum

4条回答
  •  北海茫月
    2021-01-19 14:53

    Thanks to Rob (you can find his answer above), for pointing in right direction. I just want to add a little reference so it might seem more natural than any magic.

    In the express documentation here, its mentioned that if static files like css, images etc are to be served then one need to declare it using

    app.use(express.static("_dirName"));

    I was facing same issue with using images in html code. With this, it works fine now.

提交回复
热议问题