I am integrating api
with Node.js
and I have to set src
attribute of script as server variable. Here is real code.(what i want to execute)
Server side
res.render('sample', {usertoken:'somerandomstring'});
Client side
script(src='https://apibaseurl/'+#{usertoken}+'/en.min.js')
The result I want is
script(src='https://apibaseurl/somerandomstring/en.min.js')
How to do it and what am i wrong?
Define it first:
(Client side)
script.
var usertoken ="#{usertoken}";
var script = document.createElement('script');
script.src = "https://apibaseurl/" + usertoken + "/en.min.js";
document.body.appendChild(script);
脚本(src =' https:// apibaseurl / '+ usertoken +'/ en.min.js')
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.