在html中的实现是:可以正常显示。
在js中obj.style.backgroundImage='url(../public/images/kdyj.png)'
这样就是运行不通过,找不到图片,显示错误:21cnGame.html:176 Uncaught TypeError: Cannot read property 'style' of null
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
翻译:null 没有 'style' 属性
所以你应该检查为啥 obj 是 null
你要检测一下,你的obj是什么,是不是获取dom节点错了,或者不存在