微信小程序案例-欢迎信息和当前时间

可以显示一条欢迎信息和当前时间:

// app.js
App({
  onLaunch: function () {
    // 小程序启动时执行的代码
  },
  globalData: {
    userInfo: null
  }
})
<!-- index.wxml -->
<view class="container">
  <view class="welcome">欢迎使用微信小程序</view>
  <view class="time">{{ currentTime }}</view>
</view>
/* index.wxss */
.container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100vh;
}

.welcome {
  font-size: 20px;
  margin-bottom: 20px;
}

.time {
  font-size: 40px;
  color: #333;
}

这个小程序启动后,会显示一条欢迎信息和当前时间。时间会随着系统的变化而自动更新。用户可以点击右上角的“…”按钮退出小程序。