秒轉換成年月日時分秒 秒轉換成年月日時分秒 複製文本 複製文本 <script type="text/javascript"> function copy() { var url=document.getElementById("textID"); // 獲取要操作的DOM Url2.select( ...
-
秒轉換成年月日時分秒
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
=
"點擊複製代碼"
/>