gpt4 book ai didi

javascript - Meteor.user()错误: Uncaught TypeError: Cannot read property 'name' of null

转载 作者:行者123 更新时间:2023-11-28 13:50:50 25 4
gpt4 key购买 nike

我正在使用 Meteor 框架,当我尝试将当前用户的名称返回给模板助手时,出现了此错误。

Template.user.userName = function (){
return Meteor.user().name;

}

<template name ="user">
{{userName}}
</template>

我不断收到此错误:(错误:未捕获类型错误:无法读取 null 的属性“名称”)

但是,JavaScript 控制台一切正常。

任何帮助将不胜感激。

最佳答案

如果没有用户登录,

Meteor.user() 返回 null。因此为了安全起见,您应该执行类似 Meteor.user() 的操作吗? Meteor.user().name : ''.

关于javascript - Meteor.user()错误: Uncaught TypeError: Cannot read property 'name' of null,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11087820/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com