简体   繁体   中英

How to pass an unescaped string interpolation into a script tag?

I am passing.{movies} to a main,js file but every time I call it. x is null.

script(src='../javascripts/main.js' id="load" x=!{movies})

main.js

var script_tag = document.getElementById('load');

var x = script_tag.getAttribute("x");
 console.log(x)//console returns null

fixed it

script.
      var x = !{movies};
script(src='../javascripts/main.js' id="load")

main.js

console.log(x)//correctly logs data

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM