如何加载js-yaml包?

时间:2018-05-28 17:53:12

标签: reactjs

如何在ReactApp中加载js-yaml包?

看起来当我通过npm安装它时,它被添加到package.json

  "dependencies": {
    "googleapis": "^31.0.2",
    "react": "^16.4.0",
    "react-dom": "^16.4.0",
    "react-scripts": "1.1.4",
    "yaml-js": "^0.2.3"
  },

但是当我尝试在我的代码中运行yaml.load时,我收到了错误

./src/App.js
  Line 56:  'yaml' is not defined  no-undef

1 个答案:

答案 0 :(得分:2)

以下工作

import yaml from 'yaml-js';