如何从数据库中获取并显示数据?

How to fetch and display the data from the database?

我正在尝试从我的 collection 中获取并显示项目。 我创建了模板并为其设计了每个项目。这是代码:

<template name="list_products">

    {{#each applications}}
        <div class="col-sm-4 col-lg-4 col-md-4">
            <div class="thumbnail">
                <img src="http://placehold.it/320x150" alt="">
                    <div class="caption">
                         <h4 class="pull-right">{{price}}</h4>
                         <h4><a href="#">{{title}}</a>
                                    </h4>
                                    <p>{{description}}</p>
                     </div>
            </div>
        </div>
    {{/each}}
</template>

在 .js 文件上,我创建了 return collection

中所有项目的应用程序
Template.list_products.applications = function(){
    Products.find();
}

然后我调用了 .html 文件中的模板

           {{> list_products}}

我有一次遇到这个错误 运行 "npm run start"

Refused to execute script from 'http://localhost:3000/js/jquery.js' because its MIME type ('text/html') is not executable, and strict MIME type checking is enabled

我做错了什么?这里缺少任何步骤吗?

请帮手完成。

    Template.list_products.helpers({
     applications:function(){
      return Products.find({});
      }
    });

您可以再次遍历应用程序,因为它将 return 一个游标。也可以 return Products.find({}).fetch(); 但首先尝试使用光标以查看它是否有效。