我知道可以只读取program.json文件,它列出了所有资产:https: //github.com/meteor/meteor/issues/1328#issuecomment-22913769
但这种感觉错了,我无法确定这是否会得到支持.关于资产本身的文档在这方面仍然有点稀疏(http://docs.meteor.com/#assets).
有关如何列出所有资产的最佳做法吗?
小智 3
我不知道这是否是最佳实践,但我通过使用meteor包https://github.com/peerlibrary/meteor-fs(这是一个围绕https://nodejs的薄包装器)获得了大部分的方法。 org/api/fs.html)并进行一些探索。结果资产被放入一个名为 的文件夹中app/。
我的代码如下所示:
if (Meteor.isServer) {
Meteor.startup(function() {
// clear database and load everything in the articles folder
fs.readdir("assets/app/", function(err, files) {
if (err) throw err;
files.forEach(function (val, ind, arr) {
console.log(val);
});
});
});
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
345 次 |
| 最近记录: |