大飞_dafei

导航

< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

统计

uniapp 使用Vue3 setup组合式API 引入 uniapp 的 页面生命周期

uniapp 使用Vue3 setup组合式API 引入 uniapp 的 页面生命周期

复制代码
<template>
  <view class="content">
    <image class="logo" @click="handleFei" src="/static/logo.png"></image>
    <view class="text-area">
      <text class="title" :class="title">{{ title }}</text>
    </view>

    <view>
      <text class="title"> 启动遇到报错,就是你的版本有问题,或者少依赖 </text>
    </view>
  </view>
</template>

<script setup>
import {ref} from 'vue'
import {onLaunch, onShow, onHide, onLoad} from '@dcloudio/uni-app'

const title = ref('大飞Vue3,uni-appddd启动成功了');

const handleFei = () => {
  console.log('handleFei点击事件=====');
}

onLaunch(()=>{
  console.log('App Launch ========')
})

onShow(()=>{
  console.log('App Show =====');
})

onHide(()=>{
  console.log('App Hide =======')
})

onLoad(()=>{
  setTimeout(()=>{
    console.log('App onload =======')
  },500)
})
</script>


<style>
.content {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.logo {
  height: 200rpx;
  width: 200rpx;
  margin-top: 200rpx;
  margin-left: auto;
  margin-right: auto;
  margin-bottom: 50rpx;
}

.text-area {
  display: flex;
  justify-content: center;
}

.title {
  font-size: 36rpx;
  color: #8f8f94;
}
</style>
复制代码

 

 

完整项目地址

posted on   大飞_dafei  阅读(2324)  评论(0编辑  收藏  举报

相关博文:
阅读排行:
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!
· 没有Manus邀请码?试试免邀请码的MGX或者开源的OpenManus吧
· 【自荐】一款简洁、开源的在线白板工具 Drawnix
· 园子的第一款AI主题卫衣上架——"HELLO! HOW CAN I ASSIST YOU TODAY
· Docker 太简单,K8s 太复杂?w7panel 让容器管理更轻松!
点击右上角即可分享
微信分享提示