uni-app与vue3的生命周期区别

338次阅读
没有评论

使用uniapp的api.

vue2对应uni-app的生命周期流程与 vue3对应uni-app的声明周期流程几乎没有差别,唯一的差别就是在Destory改名成了Unmount,对应的钩子名称变一下,流程没有变化。

具体可以查看文档:页面 | uni-app官网 (dcloud.net.cn)

只有页面才有onLoad、onShow、onReady钩子函数。

但是如果使用vue3怎们使用这些钩子函数呢?

组合式 API(Composition API) | uni-app官网 (dcloud.net.cn)

onLoad与created的执行先后顺序?

uni-app官网 (dcloud.net.cn)

H5与小程序不一致

一、视图绑定的变量在H5端可以不是一个reactive类型的,而在小程序端必须是reactive类型的。例如:

// template
<text>{{ str }}</text> // 这里在小程序会报错
<text>{{ str1 }}</text>

// script
const str = 'test'
const str1 = ref('test')

二、组件

<up-popup :show="showBottom" mode="bottom" @close="showBottom = false">
        <view class="popup">
          <img v-if="showBottom && freeItem.qrcode_image" class="img" :src="baseUrl + freeItem.qrcode_image" alt="" />
        </view>
      </up-popup>

正文完
 0
wujingquan
版权声明:本站原创文章,由 wujingquan 于2024-06-16发表,共计665字。
转载说明:Unless otherwise specified, all articles are published by cc-4.0 protocol. Please indicate the source of reprint.
评论(没有评论)