在线观看不卡亚洲电影_亚洲妓女99综合网_91青青青亚洲娱乐在线观看_日韩无码高清综合久久

鍍金池/ 教程/ HTML/ Meteor Assets資源
Meteor結(jié)構(gòu)
Meteor部署
Meteor排序
Meteor事件
Meteor Blaze
Meteor第一個應(yīng)用程序
Meteor發(fā)布和訂閱
Meteor環(huán)境安裝配置
Meteor package.js
Meteor在手機上運行
Meteor集合
Meteor模板
Meteor跟蹤器
Meteor發(fā)送郵件
Meteor計時器
Meteor ToDo App實例
Meteor軟件包管理
Meteor方法
Meteor表單
Meteor Assets資源
Meteor會話
Meteor EJSON
Meteor http
Meteor安全
Meteor核心API
Meteor check
Meteor帳號
Meteor教程

Meteor Assets資源

靜態(tài)服務(wù)器資源位于應(yīng)用程序內(nèi)的 private 子文件夾。在這個例子中,我們將學(xué)習(xí)如何從簡單的JSON文件中使用數(shù)據(jù)。

第1步 - 創(chuàng)建文件和文件夾

讓我們創(chuàng)建一個 private 文件夾并在這個文件內(nèi)創(chuàng)建 my-json.json 文件。我們將從命令提示符窗口來創(chuàng)建目錄,但您可以手動創(chuàng)建它。

C:\Users\Administrator\Desktop\meteorApp>mkdir private
C:\Users\Administrator\Desktop\meteorApp\private>touch my-json.json

步驟2A - 獲取文本

為了能夠從文件中讀取數(shù)據(jù),使用Assets.getText方法。要記住重要的是,這只能在服務(wù)器端來完成。由于我們使用JSON,需要分析它。

if (Meteor.isServer) {
   var myFile = JSON.parse(Assets.getText('my-json.json'));
   console.log(myFile.data.text)
}
我們可以看到,在命令提示符窗口中顯示輸出。

Meteor Assets Get Text

步驟1B - 創(chuàng)建JSON文件

我們將在 private 文件夾內(nèi)創(chuàng)建此文件。此文件將包含二進制數(shù)據(jù) "myBinary": {"$binary": "c3VyZS4="}

C:\Users\Administrator\Desktop\meteorApp\private>touch my-ejson.ejson

步驟2B - 獲取二進制

要讀取JSON文件,我們可以使用Assets.getBinary方法。
if (Meteor.isServer) {
   var myFile = Assets.getBinary('my-ejson.ejson');
   console.log(EJSON.stringify(myFile));
}
命令提示符將記錄EJSON值。

Meteor Assets Get Binary

上一篇:Meteor會話下一篇:Meteor check