最小重现代码
<template>
<view>{{ num }}</view>
</template>
<script lang="ts" setup>
const num = 12345;
</script>
结果
H5 没有问题
小程序报错「[Vue warn]: Property "num" was accessed during render but is not defined on instance. 」
更多信息
刚升级了依赖,升级前没有问题
dev-dep
"@dcloudio/types": "^3.4.8",
"@dcloudio/uni-automator": "3.0.0-4000620240325001",
"@dcloudio/uni-cli-shared": "3.0.0-4000620240325001",
"@dcloudio/uni-stacktracey": "3.0.0-4000620240325001",
"@dcloudio/vite-plugin-uni": "3.0.0-4000620240325001",
dep
"@dcloudio/uni-app": "3.0.0-4000620240325001",
"@dcloudio/uni-app-plus": "3.0.0-4000620240325001",
"@dcloudio/uni-components": "3.0.0-4000620240325001",
"@dcloudio/uni-h5": "3.0.0-4000620240325001",
"@dcloudio/uni-mp-alipay": "3.0.0-4000620240325001",
"@dcloudio/uni-mp-baidu": "3.0.0-4000620240325001",
"@dcloudio/uni-mp-jd": "3.0.0-4000620240325001",
"@dcloudio/uni-mp-kuaishou": "3.0.0-4000620240325001",
"@dcloudio/uni-mp-lark": "3.0.0-4000620240325001",
"@dcloudio/uni-mp-qq": "3.0.0-4000620240325001",
"@dcloudio/uni-mp-toutiao": "3.0.0-4000620240325001",
"@dcloudio/uni-mp-weixin": "3.0.0-4000620240325001",
"@dcloudio/uni-mp-xhs": "3.0.0-4000620240325001",
"@dcloudio/uni-quickapp-webview": "3.0.0-4000620240325001",
"@dcloudio/uni-ui": "^1.5.0",
P.S. 近 1K 的 issue 你们到底在看不看???不要寒了提 Issue 的人的心,大家提 Issue 也是为了帮助你们。
4条答案
按热度按时间yshpjwxd1#
me too, the same error
6qfn3psc2#
l miss add "setup" in . it;s works when l take it to in .vue file.
hope helping for you.
pvcm50d13#
l miss add "setup" in . it;s works when l take it to in .vue file. hope helping for you.
every script in my project uses setup, and this only happens in mp not H5, after i updated the dependencies.
it sure is a regression bug.
djmepvbi4#
试试用ref声明