在使用哦onMonted的时候提示我这个警告
并且我在进入页面时,请求数据不能渲染到页面中,
onMounted is called when there is no active component instance to be associated with. Lifecycle injection APIs can only be used during execution of setup(). If you are using async setup(), make sure to register lifecycle hooks before the first await statement.
请求一个解决方法,如果知道为什么会出现这问题的话,请告知下,真的非常感谢
部分代码
setup() {
.....
.....
onMounted(() => {
const params = {
limit: 1000,
page: 1
}
VUE_APP_BASE_API.value = process.env.VUE_APP_BASE_API
const requseArr = [
apkConfig.hardware(params),
apkConfig.platAndCate(params),
apkConfig.apkCate(params)
]
requestAll(requseArr)
.then(res => {
hardware.value = res[0]
platAndCate.value.push(...res[1])
apkCate.value.push(...res[2])
getInfo()
})
.catch(err => {
console.log(err)
})
getLangs()
})
}
onMounted
要放在setup()
函数中使用: