uniapp 使用vue3开发微信小程序,报警告onLoad is called when there is no active component instance to be associated with. Lifecycle injection APIs can only be used during execution of setup()
导致页面跳转被跳转页面生命周期函数失效
被跳转页面
<template>
<view class="main">
</view>
</template>
<script>
import {onLoad} from "@dcloudio/uni-app"
onLoad((e) => {
console.log(e);
})
</script>
<style lang="scss">
</style>
2 个回复
最佳回复
HRK_01
报错已经很明显了,你的vue3语法写错了,你使用的是语法糖写法,需要在script 后面加上setup,或者像下面这样
7***@qq.com
<script setup>
import {onLoad} from "@dcloudio/uni-app"
onLoad((e) => {
console.log(e);
})
</script>
vue3 需要把参数抛出