Zlpt_Portal/src/views/test/TimeTest.vue

50 lines
1.1 KiB
Vue

<template>
<h1>我是时间测试</h1>
<van-button type="primary" @click="toastFn">6666</van-button>
</template>
<script lang="ts" setup>
/* eslint-disable @typescript-eslint/no-explicit-any */
import moment from 'moment'
import bus from 'utils/bus'
const { proxy } = getCurrentInstance() as any
onBeforeMount(() => {
console.log('onBeforeMount')
})
onMounted(() => {
bus.on('sendMsg', getMsg)
console.log('63666', moment().format('YYYY年MM月DD日'))
let currentTime = moment('2019-02-03 12:24:36').format(
'YYYY年MM月DD日 HH时mm分ss秒'
)
console.log('currentTime', currentTime)
let diff = moment('2020-08-09').diff(moment('2020-07-08'), 'days')
console.log(diff)
let firstTime = moment().startOf('month').format('YYYY-MM-DD')
console.log('firstTime', firstTime)
})
onBeforeUnmount(() => {
console.log('onBeforeUnmount')
})
onUnmounted(() => {
console.log('onUnmounted')
})
let a = computed(() => {
return 'aaa'
})
console.log(a)
const getMsg = (val: string) => {
console.log('val', val)
}
const toastFn = () => {
proxy.$toast('6666')
}
</script>
<style scoped></style>