• 秒转换成年月日时分秒 和复制文本到剪贴板


    • 秒转换成年月日时分秒

    getDateStr (seconds) {
          let date = new Date(seconds)
          let year = date.getFullYear()
          let month = date.getMonth() + 1
          let day = date.getDate()
          let hour = date.getHours() < 10 ? '0' + date.getHours() : date.getHours()
          let minute = date.getMinutes() < 10 ? '0' + date.getMinutes() : date.getMinutes()
          let second = date.getSeconds() < 10 ? '0' + date.getSeconds() : date.getSeconds()
          let currentTime = year + '-' + month + '-' + day + ' ' + hour + ':' + minute + ':' + second
          return currentTime
        }
    getDateStr(1553161922000) // 2019-03-21 17:52:02
    • 复制文本

    <el-input :value="`${activityHost}/mobile/activity/join?id=${activityId}`" :readonly="true" ref="activeUrl">
           <template slot="append">
                   <el-button type="text" style="padding: 10px 20px;" @click="copyActiveUrl">复制</el-button>
           </template>
    </el-input>

    copyActiveUrl() {
    var activeUrl = this.$refs.activeUrl.$refs.input // 要操作的Dom
    activeUrl.select()
    document.execCommand("Copy");
    }

    或者:
    <script type="text/javascript">
    function copy()
    {
      var url=document.getElementById("textID"); // 获取要操作的DOM
      Url2.select(); // 选择对象
      document.execCommand("Copy"); // 执行浏览器复制命令
      alert("已复制好,可贴粘。");
    }
    </script>
    <textarea cols="20" rows="10" id="textID">用户定义的代码区域</textarea>
    <input type="button" onClick="copy()" value="点击复制代码" />
  • 相关阅读:
    利用JQuery一步步打造无缝滚动新闻
    asp.net操作oracle存储过程的小问题
    C# Tostring() 格式大全 [转]
    Oracle存储过程总结【转】
    JQuery中text()、html()和val()的区别
    JQuery的JSON数据格式
    HDU 1065 I Think I Need a Houseboat
    POJ1251 Jungle Roads
    HDU3177 Crixalis's Equipment
    HDU1042 N!
  • 原文地址:https://www.cnblogs.com/linjiu0505/p/10579082.html
Copyright © 2020-2023  润新知