<unicloud-db v-slot:default="{data, loading, error, options}" collection="articles" field="title,content" :getone="true" where="id=='1'">
<view>
<text>{{ data.title }}</text>
<text>{{ data.content }}</text>
</view>
</unicloud-db>
- 发布:2022-05-20 09:32
- 更新:2022-08-09 14:45
- 阅读:605
产品分类: uniapp/H5
PC开发环境操作系统: Windows
PC开发环境操作系统版本号: 21H2
HBuilderX类型: 正式
HBuilderX版本号: 3.4.7
浏览器平台: Chrome
浏览器版本: edge 101.0.1210.39
项目创建方式: HBuilderX
操作步骤:
预期结果:
正确的渲染出文章的标题和内容
正确的渲染出文章的标题和内容
实际结果:
渲染了标题 title 的值,但是直接在控制台出现错误 TypeError: Cannot read property 'title' of undefined
,并且content的内容不渲染。
渲染了标题 title 的值,但是直接在控制台出现错误 TypeError: Cannot read property 'title' of undefined
,并且content的内容不渲染。
bug描述:
当使用Vue3时,使用unicloud-db
,并且使用了getone时,直接在下面渲染整个变量data时,会以json的形式展现在界面上,但是如果具体访问某个属性,第一次属性会正常显示,但是会在控制台触发一次错误,内容为
TypeError: Cannot read property 'title' of undefined
at _createBlock.default._withCtx (http://localhost:3000/pages/agrees/privacy.vue?import&t=1652973292311:37:38)
at Proxy.renderFnWithContext (http://localhost:3000/@fs/D:/devs/HBuilderX/plugins/uniapp-cli-vite/node_modules/@dcloudio/uni-h5-vue/dist/vue.runtime.esm.js:2060:21)
at Proxy.<anonymous> (http://localhost:3000/@fs/D:/devs/HBuilderX/plugins/uniapp-cli-vite/node_modules/@dcloudio/uni-h5/dist/uni-h5.es.js:13560:75)
at renderComponentRoot (http://localhost:3000/@fs/D:/devs/HBuilderX/plugins/uniapp-cli-vite/node_modules/@dcloudio/uni-h5-vue/dist/vue.runtime.esm.js:2103:44)
at ReactiveEffect.componentUpdateFn [as fn] (http://localhost:3000/@fs/D:/devs/HBuilderX/plugins/uniapp-cli-vite/node_modules/@dcloudio/uni-h5-vue/dist/vue.runtime.esm.js:6447:34)
at ReactiveEffect.run (http://localhost:3000/@fs/D:/devs/HBuilderX/plugins/uniapp-cli-vite/node_modules/@dcloudio/uni-h5-vue/dist/vue.runtime.esm.js:187:25)
at updateComponent (http://localhost:3000/@fs/D:/devs/HBuilderX/plugins/uniapp-cli-vite/node_modules/@dcloudio/uni-h5-vue/dist/vue.runtime.esm.js:6313:26)
at processComponent (http://localhost:3000/@fs/D:/devs/HBuilderX/plugins/uniapp-cli-vite/node_modules/@dcloudio/uni-h5-vue/dist/vue.runtime.esm.js:6246:13)
at patch (http://localhost:3000/@fs/D:/devs/HBuilderX/plugins/uniapp-cli-vite/node_modules/@dcloudio/uni-h5-vue/dist/vue.runtime.esm.js:5828:21)
at patchKeyedChildren (http://localhost:3000/@fs/D:/devs/HBuilderX/plugins/uniapp-cli-vite/node_modules/@dcloudio/uni-h5-vue/dist/vue.runtime.esm.js:6611:17)
但是如果去除getone,使用for循环迭代出来的对象,则可以正常访问里面的属性。
b***@163.com
有效! 终于解决了.
2023-01-05 00:14