Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
给定 model的是一个 json 模型,它有很多从服务器返回的键属性映射,比如说{name:"hello"},我如何用新的属性键扩展它
model
{name:"hello"}
attribute key: hello attribute value: hello1
?
因为它只是一个 JavaScript 对象字面量,所以你不能说:
myJson['hello'] = 'hello1';
(假设 myJson 是您保存模型的变量。)
调用应该产生JSON.stringify():myJson
JSON.stringify()
myJson
{ 'name': 'hello', 'hello': 'hello1' }