【问题标题】:Meteor Can't load settings from the json fileMeteor 无法从 json 文件加载设置
【发布时间】:2017-06-09 11:10:30
【问题描述】:

我基于this site创建了以下settings.json文件,内容如下:

{
    "azure":{
      "container":"The container to store the data",
      "account":"The account name",
      "key":"The key that is used for authentication"
    }
}

我还创建了一个名为imports/settings/fileUploadSettings.js 的文件,其内容如下:

import { Meteor } from 'meteor/meteor';

export const FileUploadSettings= {
  'container': Meteor.settings.azure.container,
  'account': Meteor.settings.azure.account,
  'key': Meteor.settings.azure.key
}

然后我用命令运行它:

meteor --settings=./settings.json

但是当我访问http://localhost:3000 时,我收到以下错误:

TypeError: Meteor.settings.azure 未定义

【问题讨论】:

  • 你试过meteor --settings settings.json吗?
  • 如果你想在客户端访问变量,你必须将变量放在public部分
  • @none 最后这就是答案。请在下面提交。

标签: javascript json meteor ecmascript-6


【解决方案1】:

如果你想在客户端访问变量,你必须将变量放在public部分

【讨论】:

    猜你喜欢
    • 2013-12-26
    • 2017-01-06
    • 2021-08-09
    • 2020-12-08
    • 2017-08-13
    • 1970-01-01
    • 2013-09-05
    • 1970-01-01
    • 2019-05-30
    相关资源
    最近更新 更多