[英]How to use a variable as part of a JavaScript path
我有以下JS代码:
applyBefore: {
backgroundImage: 'url(/myPath/furniture/images/careers/birds/pigeon_flap_medium.gif?' + Math.random() + ')',
contentFlyOut: {
direction: 'top',
delay: 0.5,
node: '#our-history-content'
}
}
...可以正常工作,但是,我需要'/ myPath'的值等于名为'binaryContextRoot'的变量的值,因为此代码将在不同服务器上运行,其中'binaryContextRoot的值将在服务器之间不同。
我正在使用正确的语法来在'url'路径中获取'binaryContextRoot'。
我努力了:
backgroundImage: 'url("+binaryContextRoot+"/furniture/images...
其中“ binaryContextRoute”为“ / myPath”,但未成功。 无法识别/找到该路径,因此“ + binaryContextRoot +”的值不正确。
有人可以帮忙吗? :)
非常感谢
backgroundImage: 'url(' + binaryContextRoot + '/furniture/images...'
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.