<!DOCTYPE html>
<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>Document</title>
<script src="https://cdn.bootcdn.net/ajax/libs/axios/0.21.1/axios.min.js"></script>
<script src="https://apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js">
</script>
</head>
<body>
<div class="div">
<div id="div">
</div>
</div>
<button class="dog">今天你做舔狗了没</button>
<div class="box" height="500" width="500" style="border: 1px solid #333;"></div>
<script>
// function biao() {
// var div = document.getElementById("div");
// var dt = new Date(); //获取当前系统时间
// var year = dt.getFullYear(); //获取年
// var month = dt.getMonth() + 1; //获取月
// var ri = dt.getUTCDate(); //获取日
// var hours = dt.getHours(); //获取时
// var min = dt.getMinutes(); //获取分
// var sec = dt.getSeconds(); //获取秒
// var day = dt.getDay(); //获取星期几,返回的是数字,不是一二三这种中文,
// var arr = ["一", "二", "三", "四", "五", "六", "日"] //将星期返回的数字转换成中文的一二三四
// div.innerHTML = year + "年" + month + "月" + ri + "日" + hours + "时" + "<br />" + min + "分" + sec + "秒" + "星期:" + arr[day - 1];
// }
// setInterval("biao()", 1000); //setInterval定时器:第一个值为biao()这个方法,第二个值为多少秒执行一次。
function CurentTime() {
var now = new Date();
var year = now.getFullYear(); //年
var month = now.getMonth() + 1; //月
var day = now.getDate(); //日
var hh = now.getHours(); //时
var mm = now.getMinutes(); //分
var clock = year + "-";
if (month < 10)
clock += "0";
clock += month + "-";
if (day < 10)
clock += "0";
clock += day + " ";
if (hh < 10)
clock += "0";
clock += hh + ":";
if (mm < 10) clock += '0';
clock += mm;
return (clock);
}
// $(function () {
// $('.dog').click(function () {
// getnote()
// console.log(note);
// $('.box').append(CurentTime(), '<br>', ' ', note, '<br>', '<div> <div>')
// })
// })
var note = '';
function getnote() {
axios({
method: 'get',
url: 'https://api.muxiaoguo.cn/api/tiangourj',
params: {}
}).then((res) => {
note = res.data.data.comment
console.log(note);
$('.box').append(CurentTime(), '<br>', ' ', note, '<br>', '<div> <div>')
})
return note;
}
// getnote()
$(function () {
$('.dog').click(function () {
// console.log(note);
getnote()
// $('.box').append(CurentTime(), '<br>', ' ', getnote(), '<br>', '<div> <div>')
})
})
</script>
</body>
</html>
注释是修改时候打的草稿可以忽略