时间日期格式yyyy-mm-dd hh:mm:ss 和天气插件

        1. 获取时间

          getTime() {
                setInterval(() => {
                  let myDate = new Date();
                  let year = myDate.getFullYear();
                  let month = myDate.getMonth() + 1;
                  let date = myDate.getDate();
                  let hours = myDate.getHours();
                  let minutes = myDate.getMinutes();
                  let seconds = myDate.getSeconds();
                  var week = "星期" + "日一二三四五六".charAt(myDate.getDay());
                  hours = this.check(hours);
                  minutes = this.check(minutes);
                  seconds = this.check(seconds);
                  this.times =
                    year +
                    "-" +
                    month +
                    "-" +
                    date +
                    "\xa0 " +
                    hours +
                    ":" +
                    minutes +
                    ":" +
                    seconds +
                    "\xa0\xa0\xa0" +
                    week;
                }, 1000);
              },
            //不够两位补充 0
              check(i) {
                let num;
                i < 10 ? (num = "0" + i) : (num = i);
                return num;
              },
            
            

           

        2. 天气插件

          <iframe width="200" scrolling="no" height="55" frameborder="0" allowtransparency="true" src="https://i.tianqi.com?c=code&id=35&icon=1&num=5&site=12"></iframe>
          

          https://www.tianqi.com/yangshishezhi.html?id=35&h=55&w=200 根据项目去求修改天气样式

posted @ 2020-09-09 17:10  稚嫩的老大爷  阅读(175)  评论(0)    收藏  举报