第14届蓝桥杯第3期模拟赛

持续更新中······

1. 网页PPT

此题可以用原生JS也可以用jQuery

// 总页数
const sectionsCount = $("section").length;
// 当前页码
let activeIndex = 0;

// 监听用户按下空格和方向键的事件
$(document).on("keydown", (e) => {
  e.preventDefault();
  if (e.key === " " || e.key === "ArrowRight") {
    goRight();
  }
  if (e.key === "ArrowLeft") {
    goLeft();
  }
});

// 监听按钮点击事件
$(".btn.left").click(goLeft);
$(".btn.right").click(goRight);

// 切换下一张的函数
function goLeft() {
  if (activeIndex === 0) {
    return;
  }
  activeIndex -= 1;
  switchPage();
}

// 切换上一张的函数
function goRight() {
  if (activeIndex === sectionsCount - 1) {
    return;
  }
  activeIndex += 1;
  switchPage();
}

function switchPage() {
  // TODO: 请补充该函数,实现根据activeIndex切换页面的功能,并且在到达最后一页或第一页时给相应的按钮添加disable类
  // 当前section显示,其他兄弟section隐藏
  $(".container>section").eq(activeIndex).show().siblings().hide()
  // 改变左下角的页码
  $(".page").text(`${activeIndex+1} / ${sectionsCount}`)
  // 检测是否添加disable类
  if(activeIndex === 0){
    $(".btn.left").addClass("disable")
  }else if(activeIndex === sectionsCount - 1){
    $(".btn.right").addClass("disable")
  }
  // 记得也要检测是否清除disable类
  else{
    $(".btn.left").removeClass("disable")
    $(".btn.right").removeClass("disable")
  }
}

2. 西游记之西天取经

每个子项的animation属性值添加infinite即可

.actor:first-child {
    width: 200px;
    height: 180px;
    background: url(../images/west_01.png) no-repeat;
    /* TODO 填空 */
    animation: a1 0.8s steps(8) infinite;
}
.actor:nth-child(2) {
    width: 200px;
    height: 180px;
    background: url(../images/west_02.png) no-repeat;
    /* TODO 填空 */
    animation: a2 0.8s steps(8) infinite;
}
.actor:nth-child(3) {
    width: 170px;
    height: 240px;
    background: url(../images/west_03.png) no-repeat;
    /* TODO 填空 */
    animation: a3 0.8s steps(8) infinite; 
}
.actor:last-child {
    width: 210px;
    height: 200px;
    background: url(../images/west_04.png) no-repeat;
    /* TODO 填空 */
    animation: a4 0.8s steps(8) infinite;
}

4. 蓝桥校园一卡通

		// 获取DOM元素对象
		const studentName = document.getElementById("studentName"); // 姓名
		const studentId = document.getElementById("studentId");  // 学号
		const college = document.getElementById("college"); // 学院
		const submit = document.getElementById("submit");  // 制卡按钮
		const cardStyle = document.getElementById("cardStyle"); // 卡片
		const item = document.querySelectorAll(".item") // 卡片项
		const vail_name=document.getElementById("vail_name")// 姓名错误提示项
		const vail_studentId=document.getElementById("vail_studentId") //学号错误提示项
		submit.onclick = () => {
			// TODO 待补充代码
			// 记得初始时要清除错误提示及错误样式
			vail_name.style.display="none"
			vail_studentId.style.display="none"
			studentName.parentElement.classList.remove("has-error")
			studentId.parentElement.classList.remove("has-error")
			console.log(studentName.value);
			// 不要将正则表达式写成模板字符串形式`/^[\u4e00-\u9fa5]{2,4}$/`
			if(!(/^[\u4e00-\u9fa5]{2,4}$/.test(studentName.value))){
				// 添加错误样式
				studentName.parentElement.classList.add("has-error")
				// 显示错误提示
				vail_name.style.display="block"
			}
			if(!(/^[0-9]{1,12}$/.test(studentId.value))){
				studentId.parentElement.classList.add("has-error")
				vail_studentId.style.display="block"
			}
			if(!(/^[\u4e00-\u9fa5]{2,4}$/.test(studentName.value)) || !(/^[0-9]{1,12}$/.test(studentId.value))){
				return
			}
			// 将表单值填入卡片
			// 因为这里是表单内容,有用户输入的成分,所以不要用innerHTML
			item[0].textContent="姓名:"+studentName.value
			item[1].textContent="学号:"+studentId.value
			item[2].textContent="学院:"+college.value

			// 添加 showCard 类显示放大一卡通的动画,请勿删除
			cardStyle.classList.add('showCard') 
		}
		
		// 这是我自己额外加的复位功能
		// cardStyle.οnclick=function(){
		// 	cardStyle.classList.remove('showCard')
		// 	item[0].textContent=""
		// 	item[1].textContent=""
		// 	item[2].textContent=""
		// 	studentName.value=""
		// 	studentId.value=""
		// 	college.value=""
		// }

5. 会员权益领取中心

很奇怪,写了这么一点都通过了,后续再补充
在这里插入图片描述

<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>会员权益领取中心</title>
    <link rel="stylesheet" href="css/style.css" />
  </head>
  <body>
    <header>
      <img src="./images/top_banner.png" alt="">
      <div class="user">
        <img src='./images/touxiang.png'>
        <div></div>
      </div>
    </header>
  </body>
</html>

/* TODO: 待补充代码*/
*{
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}
li{
    list-style: none;
}
a{
    text-decoration: none;
}
header{
    height: 240px;
    background-color: #000;
    
}
header>img{
    width: 100%;
}
.user{
    position: absolute;
    left: 1000px;
    top:32px;
    width: 290px;
    height: 176px;
    background-image: linear-gradient(180deg, #191720 0%, #080810 100%);
    border-radius: 4px;
}
.user img{
    position: absolute;
    left: 24px;
    top: 41px;
}

8. 封装Promisefy函数

注意这里有return的嵌套,就是promisefy函数返回的是一个函数,返回的该函数的返回值是一个promise对象

const fs = require('fs')
const path = require('path')
const textPath = path.join(__dirname, '/test.md')

// 读取示例文件
fs.readFile(textPath, 'utf8', (err, contrast) => {
  // 通过promisefy转化为链式调用
  const readFileSync = promisefy(fs.readFile)

  readFileSync(textPath, 'utf8')
    .then((res) => {
      console.log(res === contrast) // 此处结果预期:true,即promise返回内容与前面读取内容一致
    })
    .catch((err) => {})
})

// promisefy()返回一个函数,返回的该函数的返回值是Promise对象
const promisefy = (fn) => {
  // TODO 此处完成该函数的封装
  // ‘...args’表示剩余参数
  return function(...args){
    return new Promise((resolve,reject)=>{
      fn(...args,(err,data)=>{
        if(err) reject(err);
        resolve(data)
      })
    })
  }
}

module.exports = promisefy // 请勿删除该行代码

10. 分页组件

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值