html5中的规定为了安全起见,不会执行innerHTML中插入的<script>的代码。
可以创建<script>标签存放数据,onLoad调用

let scripts = document.createElement('script');
				this.$nextTick(() => {
					scripts.innerHTML =
						`
				// window.onload = function () {
					setTimeout(()=>{
					 console.log('执行页面刷新')
					console.log(siteList,'=============')
				            for (var i = 0; i < siteList.length; i++) {
				                switch (siteList[i]) {
				                    case "前部":
				                        tosear(document.querySelector(".top1"));
				                        break;
				                    case "右前":
				                        tosear(document.querySelector(".top2"));
				                        break;
				                    case "右中 ":
				                        tosear(document.querySelector(".top3"));
				                        break;
				                    case "右后":
				                        tosear(document.querySelector(".top4"));
				                        break;
				                    case "后部":
				                        tosear(document.querySelector(".top5"));
				                        break;
				                    case "左后":
				                        tosear(document.querySelector(".top6"));
				                        break;
				                    case "左中":
				                        tosear(document.querySelector(".top7"));
				                        break;
				                    case "左前":
				                        tosear(document.querySelector(".top8"));
				                        break;
				                    case "顶部":
				                        tosear(document.querySelector(".top9"));
				                        break;
				                    case "底部":
				                        tosear(document.querySelector(".top10"));
				                }
				            }
							},1000)
				        // }
				        function tosear(e) {
				            let top1 = e.className;
				            top1 = top1.replace("history", "").trim()
				            if (e.classList.contains('history')) {
				                document.getElementsByClassName(top1)[1].style.display = "none"
				                e.classList.remove('history')
				                e.children[0].classList.remove('fzcolor')
				            } else {
				                document.getElementsByClassName(top1)[1].style.display = "block"
				                e.classList.add('history')
				                e.children[0].classList.add('fzcolor')
				
				            }
				        }
				`
					document.body.appendChild(scripts);
Logo

华为开发者空间,是为全球开发者打造的专属开发空间,汇聚了华为优质开发资源及工具,致力于让每一位开发者拥有一台云主机,基于华为根生态开发、创新。

更多推荐