Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/meteor/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/sql-server-2008/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Meteor/Blaze打印对象作为JSON_Meteor_Meteor Blaze - Fatal编程技术网

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}
参考:

我实际使用的开发人员助手定义如下,并且是我自己的:


我实际上使用了一个定义如下的开发人员助手,它位于我自己的系统中: