您现在的位置是:首页 > 电脑技术查询 > web开发

哪位高手能帮小弟我解释一下下面这段代码

编辑:chaxungu时间:2022-10-02 23:16:55分类:web开发

谁能帮我解释一下下面这段代码
(editor.options.relativePath ? img.getAttribute( "src", 2 ).replace( "&", "&" ) : img.src.replace( "&", "&" ))

------解决方案--------------------
是editor.options.relativePath就得到src属性并用&替换&(img.getAttribute( "src", 2 ).replace( "&", "&" )) 不是就直接用替换&(
------解决方案--------------------

等价于
if (editor.options.relativePath ){
img.getAttribute( "src", 2 ).replace( "&", "&" ) :
}else{
img.src.replace( "&", "&" )
}
------解决方案--------------------
探讨
等价于
if (editor.options.relativePath ){
img.getAttribute( "src", 2 ).replace( "&", "&" ) :
}else{
img.src.replace( "&", "&" )
}