需要更改的格式: 2024年5月31日13:00
<template>
<div>
{{getCurrentDateTime()}}
</div>
</template>
<script>
export default{
data(){
return{
time:"",
}
},
methods:{
getCurrentDateTime() {
const now = new Date();
const year = now.getFullYear();
const month = (now.getMonth() + 1).toString().padStart(2, '0');
const day = now.getDate().toString().padStart(2, '0');
const hours = now.getHours().toString().padStart(2, '0');
const minutes = now.getMinutes().toString().padStart(2, '0');
return this.time = `${year}年${month}月${day}日 ${hours}:${minutes}`;
}
}
}
</script>
<style>
</style>