Meteor/Blaze打印对象作为JSON
全部, 我在《流星/火焰》中找到了一个目标。我试过这个Meteor/Blaze打印对象作为JSON,meteor,meteor-blaze,Meteor,Meteor Blaze,全部, 我在《流星/火焰》中找到了一个目标。我试过这个 {{data}} 和它的输出 [object Object] 有什么方法可以让它输出JSON吗?如果您试图在该对象中返回值,则需要使用JS点表示法 {{foo.bar} 其中如果您试图在该对象中返回值,则需要使用JS点符号 {{foo.bar} 其中如果要在Blaze视图中以JSON格式打印JSON对象,可能需要查看JSON.stringify()方法 Home.js[助手示例] import './Home.html'; Tem
{{data}}
和它的输出
[object Object]
有什么方法可以让它输出JSON吗?如果您试图在该对象中返回值,则需要使用JS点表示法
{{foo.bar}
其中如果您试图在该对象中返回值,则需要使用JS点符号
{{foo.bar}
其中如果要在Blaze视图中以JSON格式打印JSON对象,可能需要查看
JSON.stringify()
方法
Home.js[助手示例]
import './Home.html';
Template.home.helpers({
jsonPrint(jsonObject) { // with Latest Javascript ECMAScript 2015+
return JSON.stringify(jsonObject);
}
})
<template name="home">
<body>
<p>
JSON output:
</p>
<div class="code">
{{jsonPrint yourJsonObject}}
</div>
</body>
</template>
Home.html[您的Blaze视图]
import './Home.html';
Template.home.helpers({
jsonPrint(jsonObject) { // with Latest Javascript ECMAScript 2015+
return JSON.stringify(jsonObject);
}
})
<template name="home">
<body>
<p>
JSON output:
</p>
<div class="code">
{{jsonPrint yourJsonObject}}
</div>
</body>
</template>
JSON输出:
{{jsonPrint yourJsonObject}
参考:
如果要在Blaze视图中以JSON格式打印JSON对象,可能需要查看
JSON.stringify()
方法
Home.js[助手示例]
import './Home.html';
Template.home.helpers({
jsonPrint(jsonObject) { // with Latest Javascript ECMAScript 2015+
return JSON.stringify(jsonObject);
}
})
<template name="home">
<body>
<p>
JSON output:
</p>
<div class="code">
{{jsonPrint yourJsonObject}}
</div>
</body>
</template>
Home.html[您的Blaze视图]
import './Home.html';
Template.home.helpers({
jsonPrint(jsonObject) { // with Latest Javascript ECMAScript 2015+
return JSON.stringify(jsonObject);
}
})
<template name="home">
<body>
<p>
JSON output:
</p>
<div class="code">
{{jsonPrint yourJsonObject}}
</div>
</body>
</template>
JSON输出:
{{jsonPrint yourJsonObject}
参考:
我实际使用的开发人员助手定义如下,并且是我自己的:
我实际上使用了一个定义如下的开发人员助手,它位于我自己的系统中: