这可以工作,并且图像可以渲染。
body.style.backgroundImage = 'url(0.gif)';
这是行不通的,并且图像根本无法渲染。
body.style.backgroundImage = 'url(0.gif) no-repeat center center fixed';
控制台中没有错误。
我在这里想念什么?这应该起作用了。第二句在语法上是正确的,对吗?
最佳答案
请改用body.style.background
。 body.style.backgroundImage
仅用于图像。
关于javascript - 语法错误-JS-background.style.backgroundImage,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/40330498/