137.DOM效果实现:百度换肤

案例html与css代码如下

<style>
			body{
				background-image: url(./src/7.jpg);
				background-size: 100% 800px;
			}
			img{
				width: 120px;
				height: 60px;
			}
		</style>
		<img src="./src/7.jpg">
		<img src="./src/8.jpg">
		<img src="./src/9.jpg">

效果为如下

1. 获取元素div1,div2,div3,body

var imgs=document.getElementsByTagName("img")
var srcarr=["./src/7.jpg","./src/8.jpg","./src/9.jpg"]

2.设计点击事件将对应的src给body属性

imgs[i].onclick=function(){
					document.body.style.backgroundImage=`url("${srcarr[i]}")`
				}

3.for循环

for(let i=0;i<imgs.length;i++){
				imgs[i].onclick=function(){
					document.body.style.backgroundImage=`url("${srcarr[i]}")`
				}
			}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
{ type: "searchSelect", placeholder: "签约机构", valueName: 'signOrganId', optionName: "label", searchItemName: "label", optionId: "key", searchApi:commonService.orgPageList({}).then(res=>{ const {retData}=res retData.map(item=>{ return {key: item.id, label: item.organName, value: item.id,} }) }) }, 分析一下此段代码的报错 汉语解释index.jsx:55 Uncaught TypeError: item.searchApi is not a function at searchQuery (index.jsx:55:1) at onFocus (index.jsx:129:1) at onContainerFocus (BaseSelect.js:326:1) at HTMLUnknownElement.callCallback (react-dom.development.js:188:1) at Object.invokeGuardedCallbackDev (react-dom.development.js:237:1) at invokeGuardedCallback (react-dom.development.js:292:1) at invokeGuardedCallbackAndCatchFirstError (react-dom.development.js:306:1) at executeDispatch (react-dom.development.js:389:1) at executeDispatchesInOrder (react-dom.development.js:414:1) at executeDispatchesAndRelease (react-dom.development.js:3278:1) at executeDispatchesAndReleaseTopLevel (react-dom.development.js:3287:1) at forEachAccumulated (react-dom.development.js:3259:1) at runEventsInBatch (react-dom.development.js:3304:1) at runExtractedPluginEventsInBatch (react-dom.development.js:3514:1) at handleTopLevel (react-dom.development.js:3558:1) at batchedEventUpdates$1 (react-dom.development.js:21871:1) at batchedEventUpdates (react-dom.development.js:795:1) at dispatchEventForLegacyPluginEventSystem (react-dom.development.js:3568:1) at attemptToDispatchEvent (react-dom.development.js:4267:1) at dispatchEvent (react-dom.development.js:4189:1) at unstable_runWithPriority (scheduler.development.js:653:1) at runWithPriority$1 (react-dom.development.js:11039:1) at discreteUpdates$1 (react-dom.development.js:21887:1) at discreteUpdates (react-dom.development.js:806:1) at dispatchDiscreteEvent (react-dom.development.js:4168:1)
07-13

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值