纷享销客开发者手册 纷享销客开发者手册
  • APL开发手册
  • PWC开发手册
  • OpenAPI 文档
  • 自定义组件(PC端)
  • 自定义组件(小程序)
  • 自定义插件(PC端)
  • 自定义插件(小程序)
  • 第三方集成插件(H5)
  • API(PC端)
  • API(小程序)
  • Fx DevTools
更新日志
  • 简体中文
  • English
  • 自定义组件(PC端)
  • 自定义组件(小程序)
  • 自定义插件(PC端)
  • 自定义插件(小程序)
  • 第三方集成插件(H5)
  • API(PC端)
  • API(小程序)
  • Fx DevTools
更新日志
  • 简体中文
  • English
  • 入门

  • 组件

  • 示例

    • 定制化打印
    • 定制化图表
    • 嵌入第三方企业系统
    • 自定义登录
    • 展示当前时间
      • 实际的展示效果
  • 常见问题

目录

展示当前时间

# 展示当前时间

这篇文章便教你如何动态展示当前时间。

<template>
  <div class="clock-container">
    <div class="clock">
      <div class="time-display">
        <div class="neon-text">{{ hours }}</div>
        <div class="separator">:</div>
        <div class="neon-text">{{ minutes }}</div>
        <div class="separator">:</div>
        <div class="neon-text">{{ seconds }}</div>
      </div>
      <div class="date-display neon-text-small">{{ currentDate }}</div>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      hours: '00',
      minutes: '00',
      seconds: '00',
      currentDate: ''
    };
  },
  methods: {
    updateTime() {
      const now = new Date();
      this.hours = String(now.getHours()).padStart(2, '0');
      this.minutes = String(now.getMinutes()).padStart(2, '0');
      this.seconds = String(now.getSeconds()).padStart(2, '0');
      this.currentDate = now.toLocaleDateString('zh-CN', {
        year: 'numeric',
        month: 'long',
        day: 'numeric',
        weekday: 'long'
      });
    }
  },
  mounted() {
    this.updateTime();
    setInterval(this.updateTime, 1000);
  }
};
</script>

<style scoped>
.clock-container {
  display: flex;
  justify-content: center;
  align-items: center;
  height: 100%;
  background: radial-gradient(circle at center, #1a1a1a, #000000);
  perspective: 1000px;
}

.clock {
  padding: 2rem 4rem;
  border-radius: 20px;
  background: rgba(0, 0, 0, 0.8);
  box-shadow: 0 0 20px rgba(0, 0, 255, 0.3),
              0 0 40px rgba(0, 0, 255, 0.2),
              0 0 60px rgba(0, 0, 255, 0.1);
  transform-style: preserve-3d;
  animation: float 6s ease-in-out infinite;
}

.time-display {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-family: 'Arial', sans-serif;
  font-size: 5rem;
  margin-bottom: 1rem;
}

.neon-text {
  color: #fff;
  text-shadow: 0 0 5px #fff,
               0 0 10px #fff,
               0 0 20px #0ff,
               0 0 30px #0ff,
               0 0 40px #0ff;
  animation: glow 1s ease-in-out infinite alternate;
}

.neon-text-small {
  font-size: 1.5rem;
  color: #fff;
  text-shadow: 0 0 5px #fff,
               0 0 10px #0ff;
  text-align: center;
}

.separator {
  color: #0ff;
  animation: blink 1s infinite;
}

.date-display {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid rgba(0, 255, 255, 0.2);
}

@keyframes float {
  0%, 100% {
    transform: translateY(0) rotateX(0);
  }
  50% {
    transform: translateY(-20px) rotateX(5deg);
  }
}

@keyframes glow {
  from {
    text-shadow: 0 0 5px #fff,
                 0 0 10px #fff,
                 0 0 20px #0ff,
                 0 0 30px #0ff;
  }
  to {
    text-shadow: 0 0 10px #fff,
                 0 0 20px #fff,
                 0 0 30px #0ff,
                 0 0 40px #0ff,
                 0 0 50px #0ff;
  }
}

@keyframes blink {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.3;
  }
}

/* 添加响应式设计 */
@media (max-width: 768px) {
  .time-display {
    font-size: 3rem;
  }
  
  .neon-text-small {
    font-size: 1rem;
  }
  
  .clock {
    padding: 1.5rem 2rem;
  }
}
</style>

# 实际的展示效果

<video src="https://a9.fspage.com/FSR/uipaas/pwcdoc/custom-component-web/dashboard/datetime.mp4" style="width: 100%;" controls></video>
显示代码 复制代码 复制代码
自定义登录
自定义组件的data属性

← 自定义登录 自定义组件的data属性→

  • 跟随系统
  • 浅色模式
  • 深色模式
  • 阅读模式