gpt4 book ai didi

javascript - 主干模型 : empty attribute with get method but in attributes object

转载 作者:行者123 更新时间:2023-12-03 12:21:13 25 4
gpt4 key购买 nike

我有这些行:

console.log(JSON.stringify(this.model.attributes));
console.log(this.model.get('name'));

这是输出:

"{"name":"ffg","key":"1c277f82-f093-d359-4cfb-febe4614a3b1"}"
""

我从 Backbone 开始。有什么想法为什么对象在属性中但使用 get 方法返回空吗?

编辑:

这不会影响答案,但我正在使用 Phone Gap。

2 个 console.log 是彼此相邻的行。

编辑2:

var temp = _(this.model.attributes).clone();
console.log(JSON.stringify(temp));
console.log(temp.name);

此日志:

{"name":"ss","questions":[],"order":0,"key":"5c35c304-4863-02c0-4d18-101c655aa4ae"}
""

最佳答案

我会考虑记录 this.model 并在浏览器(例如 Chrome 或 Firefox)中检查该对象,然后查看该对象的 attribute 属性。确保 name 属性按照您的预期进行定义。另外,请确保不会触发可能修改模型对象的事件。

关于javascript - 主干模型 : empty attribute with get method but in attributes object,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24442577/

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