【发布时间】:2019-08-15 21:52:27
【问题描述】:
我无法访问任何对象属性,一直未定义。
我试过了
console.log(JSON.parse(this.$store.state.user.userId));
和
console.log(JSON.parse(this.$store.state.user[0].userId));
当我这样做时
console.log(JSON.parse(this.$store.state.user.userId));
我明白了
"SyntaxError: Unexpected token u in JSON at position 0"
当我这样做的时候
console.log(JSON.parse(this.$store.state.user));
我得到了对象,我可以看到属性。只是每当我尝试访问它们时,我都会得到undefined。
【问题讨论】:
-
您也必须发布对象的内容。但我的猜测是一个错字
标签: javascript vue.js