🌏个人博客主页:

前言: 前段时间学习了JavaScript,然后写了一个todoList小项目,现在和大家分享一下我的清单以及如何实现的,希望对大家有所帮助

🔥🔥🔥文章专题todoList清单

😽感谢大家的点赞👍收藏⭐️评论✍您的一键三连是我更新的动力 💓 


 清单效果:

页面展示: 

 tab-工作-tab-生活-tab-学习-tab-健康:

功能介绍和代码详细解释:

我一共写了4个页面,但是每个页面都是基本一样的,所以我通过第一个页面向大家展示我的功能都有哪些并且是如何实现的

大体思路: 

现在我来介绍一下我大体是如何实现的,首先我创造两个二维数组(一个arrList1数组储存我的未完成内容,一个arrList2数组储存我的已完成内容),还有一个全局变量   dataId,dataId在这里的作用非常大,dataId通过tab点击可以改变我的dataId的内容,然后显示我的第几个页面和改变我的二维数组的第一个下标的值(四个页面我都设置了相class=“note”属性,所以可以通过tab关联的dataId显示我的第几个note和转换我的第几个数组

提示:(第一个页面是我的arrList1[0]和arrList2[0])

每一个页面的内容的存储都相当于两个一维数组

 1 全局dataId和二维数组显示:
  // 判断到第几个notelet dataId = 1//定义数组if (!this.localStorage.getItem('arr')) {localStorage.setItem('arr', "[[], [], [], []]")} else if (!this.localStorage.getItem('arr1')) {localStorage.setItem('arr1', "[[], [], [], []]")}//我的未完成数组const arrList1 = JSON.parse(localStorage.getItem('arr'))//我的已完成数组const arrList2 = JSON.parse(localStorage.getItem('arr1'))
2 更新未完成和已完成:

因为更新已完成和未完成相似 ,所以下面我就通过更新未完成来和大家讲解,关于更新添加,我是通过将我的本地存储解析成数组然后遍历将这些内容通过join返回成一个字符串,添加到我的un_ul里面,最终显示在页面当中

// 更新未完成function renderUnfinished() {let un_ul = document.querySelector(`.note:nth-child(${dataId}) .uul-unfinished`);const listItems = JSON.parse(localStorage.getItem('arr'))[dataId - 1].map((taskText, index) => {return `<li><a href="#" class="task-icon finished" data-name="${index}"></a><div class="center-item">${taskText}</div><div class="timing">定时<select data-name="${index}" id="timing-list" class="timeNum"><option value="0">0min</option><option value="1">1min</option><option value="2">2min</option><option value="3">3min</option><option value="4">4min</option><option value="5">5min</option></select></div><div class="delete task-icon" data-id="${index}"></div></li>`}).join('')console.log(JSON.parse(localStorage.getItem('arr'))[dataId - 1])un_ul.innerHTML = listItems}// 更新已完成function renderFinished() {let ul = document.querySelector(`.note:nth-child(${dataId}) .uul-finished`)const listItems = JSON.parse(localStorage.getItem('arr1'))[dataId - 1].map((taskText, index) => {return `<li><a href="#" class="task-icon finished"  data-name="${index}"></a><div class="center-item">${taskText}</div><div class="timing">定时<select data-name="${index}" id="timing-list" class="timeNum"><option value="0">0min</option></select></div><div class="delete task-icon" data-id="${index}"></div></li>`}).join('')ul.innerHTML = listItems}
3 input输入框回车输入内容:

 第一步获得我的input标签,然后我给我的input标签添加键盘事件监听,如果监听到点击键盘的回车Enter键,并且我的内容不为空,然后就添加给我的数组和我的本地存储,并且通过我的 renderUnfinished方法进行显示,最后将我的input标签内容变为空

  // 如果按下了回车事件let inputTask = document.querySelector('#task')inputTask.addEventListener('keydown', function (e) {if (e.key === 'Enter') {let newTaskText = inputTask.value.trim()if (newTaskText !== '') {arrList1[dataId - 1].push(newTaskText)localStorage.setItem('arr', JSON.stringify(arrList1))//更新未完成事件界面renderUnfinished()//将input设为空inputTask.value = ''}}})
4 点击删除未完成:

 首先给父级元素添加点击事件,通过dataID来获得是第几个li标签然后删除该位置的数组内容(dataID和一维数组是关联的)通过dataID可以当中数组下标得到内容所以可以直接使用dataID进行数组操作,定位到第几个内容然后直接进行删除操作,然后改变本地存储,最后进行遍历显示

    // 删除未完成//un_ul是存储内容li的父级ul标签,这里使用冒泡来获得liun_ul.addEventListener('click', function (e) {//判断点击的是否是delete小图标if (e.target.classList.contains('delete')) {let dataID = parseInt(e.target.dataset.id)arrList1[dataId - 1].splice(dataID, 1)console.log(arrList1)//往本地存储添加相同密匙的内容只会覆盖localStorage.setItem('arr', JSON.stringify(arrList1))renderUnfinished()}})
5 点击删除已完成:

这里的操作和上面的删除未完成操作一样,只是获取的父级元素不一样

    // 删除已完成ul.addEventListener('click', function (e) {if (e.target.classList.contains('delete')) {let dataID = parseInt(e.target.dataset.id)// console.log(dataID)arrList2[dataId - 1].splice(dataID, 1)localStorage.setItem('arr1', JSON.stringify(arrList2))renderFinished()}})
6 删除全部未完成:

这个就是点击全部已完成的按钮,然后将数组和本地存储清空,最后进行更新

    //删除全部已完成text1.addEventListener('click', function (e) {if (e.target.tagName === 'SPAN') {arrList2[dataId - 1] = []localStorage.setItem('arr1', JSON.stringify(arrList2))renderFinished()}})
7 点击圆形图标未完成变成已完成:

这个就是点击li标签的第一个小图标,然后使得该内容从未完成变成已完成,内部操作就是点击该图标,通过dataName为下标来获得该处的内容,然后将该内容添加到已完成的数组里面,最后将该内容在未完成里面删除,最后修改本地存储,然后进行更新

    // 点击未完成按钮任务变成完成un_ul.addEventListener('click', function (e) {if (e.target.classList.contains('finished')) {let dataName = parseInt(e.target.dataset.name);arrList2[dataId - 1].push(arrList1[dataId - 1][dataName]);arrList1[dataId - 1].splice(dataName, 1);localStorage.setItem('arr1', JSON.stringify(arrList2));localStorage.setItem('arr', JSON.stringify(arrList1));renderFinished();renderUnfinished();}})

8 时间提醒:

这个是我的select标签里面的option进行的change 才会触发事件监听,虽然还是冒泡,但是在if语句里面进行了判断,开始获得事件,然后添加了计时器将时间每秒减一次,当时间为0时重复上面的未完成功能到已完成的操作

  // 时间提醒un_ul.addEventListener('change', function (e) {if (e.target && e.target.classList.contains('timeNum')) {let timer = +e.target.value;let time = setInterval(function () {timer--;let dataName = parseInt(e.target.dataset.name);if (timer === 0) {arrList2[dataId - 1].push(arrList1[dataId - 1][dataName]);arrList1[dataId - 1].splice(dataName, 1);localStorage.setItem('arr', JSON.stringify(arrList1));localStorage.setItem('arr1', JSON.stringify(arrList2));renderFinished();renderUnfinished();alert('滴滴,时间到');clearInterval(time);}}, 1000)}})
9 计时器

获得当前时间进行显示 ,然后通过计时器每秒更改一次时间

// 显示当前时间function showTime() {let date = new Date()// 年月日let year = date.getFullYear()let month = date.getMonth() + 1let day = date.getDate()// 时分秒let hour = date.getHours()hour = hour < 10 ? '0' + hour : hourlet minute = date.getMinutes()minute = minute < 10 ? '0' + minute : minutelet second = date.getSeconds()second = second < 10 ? '0' + second : second// 显示let element = document.getElementById('date')element.innerHTML = '<p>' + year + '-' + month + '-' + day + ' ' + hour + ':' + minute + ':' + second + '</p>'}let ShowTime = window.setInterval(showTime, 1000)

 全部代码展示:

HTML:
<body><p id="date"></p><!-- 设置便签整体 --><div class="entire"><div class="title"><img class="pic" src="./image/title.png"><img class="pic1" src="./image/bianqian.png"></div><!-- 设置便签头部 --><div class="header"><!-- 添加输入框 --><input id="task" type="text" placeholder="添加请按回车键"></div><!-- 设置中部 --><div class="middle"><!-- 设置中间tab栏部分 --><div class="tabs"><!-- 设置4个内容便签tab --><div class="work active" data-id="1">工作</div><div class="life" data-id="2">生活</div><div class="study" data-id="3">学习</div><div class="health" data-id="4">健康</div></div><!-- 设置中间内容部分 --><div class="content"><!-- 设置第一个便签内容 --><div class="note active"><div class="work-unfinished"><div class="note-text">未完成</div><!-- 定时 --><ul class="uul-unfinished"><!-- 通过dom添加li标签 --><!-- <li><a href="#" class="task-icon finished" data-name="1"></a><div class="center-item">吃饭</div><div class="timing">定时<select data-name="${index}" id="timing-list" class="timeNum"><option value="0">0min</option><option value="1">1min</option><option value="2">2min</option><option value="3">3min</option><option value="4">4min</option><option value="5">5min</option></select></div><div class="delete task-icon" data-id="1"></div></li> --></ul></div><div class="work-finished"><div class="text"><div class="note-text">已完成</div><span class="deleteAll">删除全部</span><img src="./image/unfinished.png"></div><!-- 定时 --><ul class="uul-finished"><!-- 通过dom添加li标签 --><!-- <li><a href="#" class="task-icon unfinished"></a><div class="center-item">${taskText}</div><div class="timing">定时<select data-name="1" id="timing-list" class="timeNum"><option value="0">0min</option></select></div><div class="delete task-icon" data-id="${index}"></div></li> --></ul></div></div><!-- 设置第二个便签内容 --><div class="note"><div class="life-unfinished"><div class="note-text">未完成</div><!-- 定时 --><ul class="uul-unfinished"><!-- 通过dom添加li标签 --></ul></div><div class="life-finished"><div class="text"><div class="note-text">已完成</div><span class="deleteAll">删除全部</span><img src="./image/unfinished.png"></div><!-- 定时 --><ul class="uul-finished"><!-- 通过dom添加li标签 --></ul></div></div><!-- 设置第三个便签内容 --><div class="note"><div class="study-unfinished"><div class="note-text">未完成</div><!-- 定时 --><ul class="uul-unfinished"><!-- 通过dom添加li标签 --></ul></div><div class="study-finished"><div class="text"><div class="note-text">已完成</div><span class="deleteAll">删除全部</span><img src="./image/unfinished.png"></div><!-- 定时 --><ul class="uul-finished"><!-- 通过dom添加li标签 --></ul></div></div><!-- 设置第四个便签内容 --><div class="note"><div class="health-unfinished"><div class="note-text">未完成</div><!-- 定时 --><ul class="uul-unfinished"><!-- 通过dom添加li标签 --></ul></div><div class="health-finished"><div class="text"><div class="note-text">已完成</div><span class="deleteAll">删除全部</span><img src="./image/unfinished.png"></div><!-- 定时 --><ul class="uul-finished"><!-- 通过dom添加li标签 --></ul></div></div></div></div></div></div><script src="./todoList.js"></script>
</body>

CSS:
* {margin: 0;margin: 0;box-sizing: border-box;
}li {list-style: none;
}a {text-decoration: none;
}body {background-color: #fffbfb;background-image: url(./image/bigbgc.png);height: 1300px;background-repeat: no-repeat;background-size: cover;user-select: none;
}#date {text-align: center;height: 80px;font-size: 50px;color: #fff;
}.entire {margin: auto;width: 600px;height: 1100px;border-radius: 45px;border: 1px solid rgb(228, 228, 255);box-shadow: 5px 5px 15px rgb(201, 198, 198), -5px -5px 10px #fff;background-color: #ffefef;/* background-image: url(./image/bgc.png);background-size: contain; */
}.task-icon {cursor: pointer;font-family: 'icomoon';display: inline-block;width: 40px;height: 40px;font-size: 40px;text-align: center;border-radius: 20px;/* box-shadow: 5px 5px 5px rgb(255, 255, 255), 5px 5px 5px #fffdfd; */color: #ffffff;margin-right: 10px;margin-bottom: 9px;
}.life-finished .task-icon,
.life-unfinished .task-icon {color: #ffd1d1;
}.health-finished .task-icon,
.health-unfinished .task-icon {color: #dde6ff;
}.title {margin: auto;width: 400px;height: 100px;border-radius: 40px;text-align: center;box-shadow: 5px 5px 15px rgb(201, 198, 198), -5px -5px 10px #fff;margin-bottom: 20px;
}/* .title span {color: #d27171;font-size: 30px;margin-top: 5px;text-align: center;vertical-align: middle;
} */.title .pic {width: 80px;height: 80px;vertical-align: middle;margin-top: 10px;margin-right: 10px;
}.title .pic1 {border-radius: 12px;width: 160px;vertical-align: middle;margin-top: 10px;margin-right: 10px;
}.header input {margin-left: 105px;padding-left: 15px;width: 390px;height: 55px;border-radius: 25px;border: none;outline: none;font-size: 22px;color: #e09191;background-color: #ffefef;box-shadow: 5px 5px 15px rgb(219, 218, 218) inset, -5px -5px 10px #fff inset;
}input::placeholder {color: #f2b1b1;font-size: 21px;
}.tabs {margin-top: 35px;display: flex;gap: 10px;border-bottom: 2px solid #f0b2b2;
}.tabs div {padding: 10px 20px;background-color: #ffefef;border: 2px solid #e7b3b3;border-top-left-radius: 36px;border-top-right-radius: 36px;border-bottom: none;cursor: pointer;color: #e59898;box-shadow: 5px 5px 15px rgb(250, 241, 241) inset, -5px -5px 10px #fff inset;
}.tabs .active {background-color: #ffd5d5;
}.timing {width: 140px;text-align: center;
}#timing-list {width: 60px;color: rgb(206, 168, 168);outline: none;border-color: rgb(228, 128, 128);border-radius: 10px;margin-top: 13px;}.content {padding-top: 15px;
}.note {padding-top: 20px;margin: auto;width: 560px;height: 790px;border: 3px solid #f7dfdf;border-radius: 40px;}.note:nth-child(1) {background-color: #ffdddd;
}.note:nth-child(2) {background-color: #fffefe;
}.note:nth-child(2) .center-item {color: #da5d5d;
}.note:nth-child(3) {background-color: #ffdddd;
}.note:nth-child(3) .center-item {color: #ffffff;
}.note:nth-child(4) {background-color: #f8f9ff;
}.note:nth-child(4) .center-item {color: #7d9fb8;
}/* 设置背景图片 */
.work-unfinished,
.work-finished {background-image: url(./image/bgc.png);
}.life-finished,
.life-unfinished {background-image: url(./image/bgc1.png);background-size: cover;
}.study-unfinished,
.study-finished {background-image: url(./image/bgc2.png);
}.health-unfinished,
.health-finished {background-image: url(./image/bgc3.png);
}/* 设置完成和未完成的框的大小和样式 */
.work-unfinished,
.work-finished,
.life-unfinished,
.life-finished,
.study-unfinished,
.study-finished,
.health-unfinished,
.health-finished {padding-top: 10px;margin: auto;height: 360px;width: 510px;border-radius: 25px;border: #eadddd solid 2px;box-shadow: 5px 5px 5px rgb(223, 223, 223) inset, -5px -5px 10px #f2e8e8 inset;
}/* 设置完成和未完成之间的间隔为20px */
.work-unfinished,
.life-unfinished,
.study-unfinished,
.health-unfinished {margin-bottom: 20px;
}/* 设置完成和未完成的字体样式 */
.note-text {margin: auto;width: 140px;height: 50px;border-radius: 22px;padding-top: 5px;color: #d58585;font-size: 26px;text-align: center;
}/* 更换第三个标签主题字体颜色 */
.study-unfinished .note-text,
.study-finished .note-text {color: #ffffff;
}/* 更换第一个标签主题颜色 */
.work-finished .note-text,
.work-unfinished .note-text {box-shadow: 5px 5px 5px rgb(248, 157, 157) inset, -5px -5px 10px #f2e8e8 inset;background-color: #ffdfdf;}.life-finished .note-text,
.life-unfinished .note-text {box-shadow: 5px 5px 5px rgb(248, 157, 157) inset, -5px -5px 10px #f2e8e8 inset;background-color: #fff8f8;
}.study-unfinished .note-text,
.study-finished .note-text {box-shadow: 5px 5px 5px rgb(207, 161, 161) inset, -5px -5px 10px #f2e8e8 inset;background-color: #ffc5c5;
}.health-finished .note-text,
.health-unfinished .note-text {box-shadow: 5px 5px 5px #e3f1ff inset, -5px -5px 10px #dbdbdb inset;color: #d6e3ff;background-color: #ffffff;
}.work-finished .note-text,
.life-finished .note-text,
.study-finished .note-text,
.health-finished .note-text {margin-left: 185px;
}.uul-unfinished,
.uul-finished {margin-top: 5px;display: block;width: 510px;height: 295px;overflow-y: scroll;overflow-x: hidden;
}/* 隐藏滚动条  */
.uul-unfinished::-webkit-scrollbar,
.uul-finished::-webkit-scrollbar {width: 0;
}.uul-unfinished li,
.uul-finished li {padding: 11px;margin-top: 12px;margin-left: -10px;border-radius: 30px;display: flex;height: 60px;width: 450px;text-align: center;font-size: 17px;color: #c06666;
}.work-unfinished .uul-unfinished li,
.work-finished .uul-finished li {box-shadow: 5px 5px 15px rgb(255, 255, 255) inset, -5px -5px 10px #f2e8e8 inset;background-color: #ffc3c3;
}.life-unfinished .uul-unfinished li,
.life-finished .uul-finished li {box-shadow: 5px 5px 5px rgb(255, 211, 211) inset, -5px -5px 10px #f2e8e8 inset;background-color: #ffffff;
}.study-unfinished .uul-unfinished li,
.study-finished .uul-finished li {box-shadow: 5px 5px 15px rgb(255, 255, 255) inset, -5px -5px 10px #f2e8e8 inset;background-color: #ffa3a3;
}.health-unfinished .uul-unfinished li,
.health-finished .uul-finished li {box-shadow: 5px 5px 15px rgb(255, 255, 255) inset, -5px -5px 10px #e6f8ff inset;background-color: #ffffff;
}.center-item {width: 250px;height: 20px;overflow: hidden;margin-top: 10px;text-align: left;}.uul-finished .center-item {text-decoration: line-through;
}/* .delete {cursor: pointer;color: #ffffff;height: 36px;width: 36px;
} *//* 设置变签内容不可看 */
.note {display: none;
}/* 设置变迁内容可看 */
.content .active {display: block;
}/* 设置完成文字图片在一排 */
.text {display: flex;
}/* 
.deleteAll {cursor: pointer;background-image: url(./image/unfinished.png);width: 50px;height: 50px;
} */.text img {width: 30px;height: 30px;border-radius: 15px;margin-right: 10px;margin-left: 10px;margin-top: 4px;
}.text span {width: 100px;height: 40px;/* cursor: pointer;/ */text-align: center;vertical-align: middle;color: #8d2222;font-size: 20px;padding: 4px;border-radius: 15px;border: 1px solid rgb(255, 217, 142);
}
JS: 
window.addEventListener('load', function () {// 判断到第几个notelet dataId = 1//显示时间1showTime()//定义数组if (!this.localStorage.getItem('arr')) {localStorage.setItem('arr', "[[], [], [], []]")} else if (!this.localStorage.getItem('arr1')) {localStorage.setItem('arr1', "[[], [], [], []]")}const arrList1 = JSON.parse(localStorage.getItem('arr'))const arrList2 = JSON.parse(localStorage.getItem('arr1'))// 初始化所有标签页的任务列表for (let i = 1; i <= 4; i++) {dataId = irenderUnfinished()renderFinished()}//将dataId重新赋值为1dataId = 1// 如果按下了回车事件let inputTask = document.querySelector('#task')inputTask.addEventListener('keydown', function (e) {if (e.key === 'Enter') {let newTaskText = inputTask.value.trim()if (newTaskText !== '') {arrList1[dataId - 1].push(newTaskText)localStorage.setItem('arr', JSON.stringify(arrList1))//更新未完成事件界面renderUnfinished()//将input设为空inputTask.value = ''}}})// 点击tabslet tabs = document.querySelector('.tabs')tabs.addEventListener('click', function (e) {if (e.target.tagName === 'DIV' && e.target.hasAttribute('data-id')) {document.querySelector('.tabs .active').classList.remove('active')e.target.classList.add('active')// 判断到第几个noteconsole.log(dataId)dataId = +e.target.dataset.idconsole.log(dataId)// console.log(dataId)document.querySelector('.content .active').classList.remove('active')document.querySelector(`.content .note:nth-child(${dataId})`).classList.add('active')// 更新两个界面// renderFinished()// renderUnfinished()bindEventListeners()}});// 绑定事件监听器function bindEventListeners() {let un_ul = document.querySelector(`.note:nth-child(${dataId}) .uul-unfinished`)let ul = document.querySelector(`.note:nth-child(${dataId}) .uul-finished`)let text1 = document.querySelector(`.note:nth-child(${dataId}) .deleteAll`)// 删除未完成un_ul.addEventListener('click', function (e) {if (e.target.classList.contains('delete')) {let dataID = parseInt(e.target.dataset.id)arrList1[dataId - 1].splice(dataID, 1)console.log(arrList1)localStorage.setItem('arr', JSON.stringify(arrList1))renderUnfinished()}})// 删除已完成ul.addEventListener('click', function (e) {if (e.target.classList.contains('delete')) {let dataID = parseInt(e.target.dataset.id)// console.log(dataID)arrList2[dataId - 1].splice(dataID, 1)localStorage.setItem('arr1', JSON.stringify(arrList2))renderFinished()}})//删除全部已完成text1.addEventListener('click', function (e) {if (e.target.tagName === 'SPAN') {arrList2[dataId - 1] = []localStorage.setItem('arr1', JSON.stringify(arrList2))renderFinished()}})// 点击未完成按钮任务变成完成un_ul.addEventListener('click', function (e) {if (e.target.classList.contains('finished')) {let dataName = parseInt(e.target.dataset.name);arrList2[dataId - 1].push(arrList1[dataId - 1][dataName]);arrList1[dataId - 1].splice(dataName, 1);localStorage.setItem('arr1', JSON.stringify(arrList2));localStorage.setItem('arr', JSON.stringify(arrList1));renderFinished();renderUnfinished();}})// 时间提醒un_ul.addEventListener('change', function (e) {if (e.target && e.target.classList.contains('timeNum')) {let timer = +e.target.value;let time = setInterval(function () {timer--;let dataName = parseInt(e.target.dataset.name);if (timer === 0) {arrList2[dataId - 1].push(arrList1[dataId - 1][dataName]);arrList1[dataId - 1].splice(dataName, 1);localStorage.setItem('arr', JSON.stringify(arrList1));localStorage.setItem('arr1', JSON.stringify(arrList2));renderFinished();renderUnfinished();alert('滴滴,时间到');clearInterval(time);}}, 1000)}})}// 更新未完成function renderUnfinished() {let un_ul = document.querySelector(`.note:nth-child(${dataId}) .uul-unfinished`);// if (!un_ul) {//   console.error('Element .note:nth-child(${dataId}) .uul-unfinished is not found.');//   return// }const listItems = JSON.parse(localStorage.getItem('arr'))[dataId - 1].map((taskText, index) => {return `<li><a href="#" class="task-icon finished" data-name="${index}"></a><div class="center-item">${taskText}</div><div class="timing">定时<select data-name="${index}" id="timing-list" class="timeNum"><option value="0">0min</option><option value="1">1min</option><option value="2">2min</option><option value="3">3min</option><option value="4">4min</option><option value="5">5min</option></select></div><div class="delete task-icon" data-id="${index}"></div></li>`}).join('')console.log(JSON.parse(localStorage.getItem('arr'))[dataId - 1])un_ul.innerHTML = listItems}// 更新已完成function renderFinished() {let ul = document.querySelector(`.note:nth-child(${dataId}) .uul-finished`)// if (!ul) {//   console.error('Element .note:nth-child(${dataId}) .uul-finished is not found.')//   return// }const listItems = JSON.parse(localStorage.getItem('arr1'))[dataId - 1].map((taskText, index) => {return `<li><a href="#" class="task-icon finished"  data-name="${index}"></a><div class="center-item">${taskText}</div><div class="timing">定时<select data-name="${index}" id="timing-list" class="timeNum"><option value="0">0min</option></select></div><div class="delete task-icon" data-id="${index}"></div></li>`}).join('')ul.innerHTML = listItems}// 显示当前时间function showTime() {let date = new Date()// 年月日let year = date.getFullYear()let month = date.getMonth() + 1let day = date.getDate()// 时分秒let hour = date.getHours()hour = hour < 10 ? '0' + hour : hourlet minute = date.getMinutes()minute = minute < 10 ? '0' + minute : minutelet second = date.getSeconds()second = second < 10 ? '0' + second : second// 显示let element = document.getElementById('date')element.innerHTML = '<p>' + year + '-' + month + '-' + day + ' ' + hour + ':' + minute + ':' + second + '</p>'}let ShowTime = window.setInterval(showTime, 1000)// 初始化事件监听器bindEventListeners()})

到这里就讲完了,感谢大家的观看,希望大家有所收获

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。
如若转载,请注明出处:http://www.pswp.cn/bicheng/93062.shtml
繁体地址,请注明出处:http://hk.pswp.cn/bicheng/93062.shtml
英文地址,请注明出处:http://en.pswp.cn/bicheng/93062.shtml

如若内容造成侵权/违法违规/事实不符,请联系英文站点网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

Mac M1探索AnythingLLM+Ollama+知识库问答

AnythingLLM内置 RAG、AI Agent、可视化/无代码的 Agent 编排&#xff0c;支持多家模型与本地/云端向量库&#xff0c;并提供多用户与可嵌入的聊天组件&#xff0c;用来快速验证“知识 模型 工具”拼成的 AI 应用。 1 AnythingLLM、Ollama准备 1&#xff09;AnythingLLM 打…

【 Navicat Premium 17 完全图形化新手指南(从零开始)】

Navicat Premium 17 完全图形化新手指南&#xff08;从零开始&#xff09; 一、准备阶段&#xff1a;清理现有环境 1. 删除已创建的测试数据库&#xff08;如需重新开始&#xff09;打开Navicat Premium 17 双击桌面图标启动程序在左侧连接面板中找到你的MySQL连接&#xff08;…

Web学习笔记5

Javascript概述1、JS简介JS是运行在浏览器的脚本编程语言&#xff0c;最初用于Web表单的校验。现在的作用主要有三个&#xff1a;网页特效、表单验证、数据交互JS由三部分组成&#xff0c;分别是ECMAscript、DOM、BOM&#xff0c;其中ECMAscript规定了JS的基本语法和规则&#…

部署一个开源的证件照系统

以下数据来自官方网站,记录下来,方便自己 项目简介 &#x1f680; 谢谢你对我们的工作感兴趣。您可能还想查看我们在图像领域的其他成果&#xff0c;欢迎来信:zeyi.linswanhub.co. HivisionIDPhoto 旨在开发一种实用、系统性的证件照智能制作算法。 它利用一套完善的AI模型工作…

Linux客户端利用MinIO对服务器数据进行同步

接上篇 Windows客户端利用MinIO对服务器数据进行同步 本篇为Linux下 操作&#xff0c;先看下我本地的系统版本 所以我这里下载的话&#xff0c;是AMD64 文档在这 因为我这里只是需要用到客户端&#xff0c;获取数据而已&#xff0c;所以我只需要下载个MC工具用来数据获取就可以…

Docker 中部署 MySQL 5.7 并远程连接 Navicat 的完整指南

个人名片 &#x1f393;作者简介&#xff1a;java领域优质创作者 &#x1f310;个人主页&#xff1a;码农阿豪 &#x1f4de;工作室&#xff1a;新空间代码工作室&#xff08;提供各种软件服务&#xff09; &#x1f48c;个人邮箱&#xff1a;[2435024119qq.com] &#x1f4f1…

自己动手造个球平衡机器人

你是否曾对那些能够精妙地保持平衡的机器设备感到好奇&#xff1f; 从无人机到独轮平衡车&#xff0c;背后都蕴藏着复杂的控制系统。 今天&#xff0c;我们来介绍一个充满挑战与乐趣的项目——制作一个球平衡机器人。这不仅是一个酷炫的摆件&#xff0c;更是一次深入学习机器…

21.Linux HTTPS服务

Linux : HTTPS服务协议传输方式端口安全性HTTP明文传输80无加密&#xff0c;可被窃听HTTPS加密传输443HTTP SSL/TLS 数据加密&#xff08;防窃听&#xff09;身份认证&#xff08;防伪装&#xff09;完整性校验&#xff08;防篡改&#xff09;OpenSSL 证书操作核心命令命令选项…

SqlSugar 跨方法 操作临时表

.net项目中时长会有用到临时表的操作结果如下所示但是在SqlSugar中可能因为会话问题导致临时表访问受限 搜索到的方式var conn (SqlConnection)sugarClient.Ado.Connection;if (conn.State ! System.Data.ConnectionState.Open) {conn.Open();}using (var cmd new SqlCommand…

怎么用飞算javaAI实现视频逐帧截图并保存

相信很多朋友都遇到过这样的需求&#xff1a;想从视频中截取特定帧作为素材&#xff0c;却苦于没有简单易用的工具&#xff0c;要么操作复杂难以精准定位&#xff0c;要么导出的图片质量不佳。市面上的视频处理软件要么功能冗余&#xff0c;要么需要付费才能使用逐帧截取功能&a…

【2】Transformers快速入门:统计语言模型是啥?

一句话看懂统计语言模型核心任务&#xff1a;教电脑判断一句话 “像不像人话” &#xff08;比如“我爱吃苹果”✅ vs “苹果吃爱我”❌&#xff09;1. 早期&#xff1a;死磕语法规则 → 失败&#xff01; 科学家思路&#xff08;1970年前&#xff09;&#xff1a; 像语文老师一…

[激光原理与应用-230]:物理学主要分支、研究对象、衍生技术及职业方向解析

物理学作为自然科学的核心学科&#xff0c;其分支体系覆盖从微观粒子到宏观宇宙的广阔领域&#xff0c;并通过交叉融合衍生出众多前沿技术。以下从经典与现代物理学分支、交叉学科、技术转化及职业方向四个维度展开分析&#xff1a;一、经典物理学分支&#xff1a;宏观世界的基…

北京JAVA基础面试30天打卡08

RocketMQ、RabbitMQ与Kafka对比及常见问题解决方案 一、概述 消息队列&#xff08;Message Queue, MQ&#xff09;是企业IT系统内部通信的核心手段&#xff0c;用于提升性能、实现系统解耦和流量削峰。它具有低耦合、可靠投递、广播、流量控制、最终一致性等功能&#xff0c;是…

【CSS 变量】让你的 CSS “活”起来:深入理解 CSS 自定义属性与主题切换

【CSS 变量】让你的 CSS “活”起来&#xff1a;深入理解 CSS 自定义属性与主题切换 所属专栏&#xff1a; 《前端小技巧集合&#xff1a;让你的代码更优雅高效》 上一篇&#xff1a; 【CSS 视觉】无需JS&#xff0c;纯 CSS 实现酷炫视觉效果&#xff08;clip-path, filter, b…

RAG初步实战:从 PDF 到问答:我的第一个轻量级 RAG 系统(附详细项目代码内容与说明)

RAG初步实战&#xff1a;从 PDF 到问答&#xff1a;我的第一个轻量级 RAG 系统 项目背景与目标 在大模型逐渐普及的今天&#xff0c;Retrieval-Augmented Generation&#xff08;RAG&#xff0c;检索增强生成&#xff09;作为连接“知识库”和“大语言模型”的核心范式&#…

自主泊车算法

看我的git 在 open space 空间下规划出⼀条⾃⻋到停⻋位的⽆碰撞轨迹 满⾜平滑约束 可跟踪 考虑动态障碍物约束 在路径不可⽤的情况下 具备重规划能⼒ 重规划时能够做到⽆缝切换 即从原路径⽆缝切换到重规划路径 ⽆明显体感 规划频率 10HZ

USB 2.0 学习(2)- 连接

上回说到 usb的信号 k 状态和 j 状态&#xff0c;补充一下 usb的一些电气小知识。 1.USB设备有四根线 电源线VBus、 D、 D-、 地线GND 2.USB主机端的 D 和 D-各有1个15k下拉电阻&#xff0c;这是为了准确检测 D还是D-线上电平的变化 因为USB总线检测USB设备是低速还是全速设备…

解锁 Appium Inspector:移动端 UI 自动化定位的利器

​ 在移动端 UI 自动化测试中&#xff0c;元素定位是绕不开的核心环节。无论是 Android 还是 iOS 应用&#xff0c;能否精准、高效地定位到界面元素&#xff0c;直接决定了自动化脚本的稳定性和可维护性。而 Appium Inspector 作为 Appium 生态中专门用于元素定位的工具&#…

机器学习概念1

了解机器学习1、什么是机器学习机器学习是一门通过编程让计算机从数据中进行学习的科学 通用定义&#xff1a;机器学习是一个研究领域让计算机无须进行明确编程就具备学习能力 工程化定义&#xff1a;一个计算机程序利用经验E来学习任务T&#xff0c;性能是P&#xff0c;如果针…

前端html学习笔记5:框架、字符实体与 HTML5 新增标签

本文为个人学习总结&#xff0c;如有谬误欢迎指正。前端知识众多&#xff0c;后续将继续记录其他知识点&#xff01; 目录 前言 一、框架标签 作用&#xff1a; 语法&#xff1a; 属性&#xff1a; 二、字符实体 作用&#xff1a; 三、html5新增标签 语义化 状态 列…