[英]Cannot assign to read only property 'displayName' of object
I am facing a simple issue I am getting the error "Cannot assign to read only property 'displayName' of object" im adding a setting where you can change your display name in the settings page.我面临一个简单的问题,我收到错误“无法分配给对象的只读属性'displayName'”,我正在添加一个设置,您可以在设置页面中更改您的显示名称。
function Changename() {
currentUser.displayName = setUserName
}
I am using firebase for this project, I cant find anywhere to change this read property to read and write in firebase.我在这个项目中使用 firebase,我找不到任何地方可以更改此读取属性以在 firebase 中读取和写入。
My guess is that your currentUser
is a reference to a User
/ UserInfo
object from Firebase Authentication.我的猜测是您的
currentUser
是对来自 Firebase 身份验证的User
/ UserInfo
object的引用。 In that case displayName
property is indeed read-only.在这种情况下,
displayName
属性确实是只读的。 If you want to change the user's display name, call updateProfile
as shown in the documentation on updating the current user's profile .如果您想更改用户的显示名称,请调用
updateProfile
,如有关更新当前用户配置文件的文档中所示。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.