React:在需要react-lazy-load

时间:2018-11-26 07:09:58

标签: reactjs lazy-loading

我正在尝试使用React Lazy Load(https://github.com/loktar00/react-lazy-load)。我需要它:  var LazyLoad = require('react-lazy-load').default;基于以下原因正在使用defaulthttps://github.com/loktar00/react-lazy-load/issues/86。另外,如果没有.default,则根本无法使用。
但是我仍然只需要newBundle.js:1 Uncaught Error: Cannot find module 'react-lazy-load'就可以了。有什么想法吗?

编辑:忘了说我一开始就已经用npm install --save react-lazy-load安装了它,它显示在我的package.json中,所以我知道它在那里。

编辑:以下是我已经安装在package.json中的软件包(不要使用webpack,请使用browserify)

  "devDependencies": {
    "colors": "1.1.2",
    "dotenv": "4.0.0",
    "eslint": "3.4.0",
    "eslint-plugin-import": "1.14.0",
    "eslint-plugin-react": "6.1.2",
    "expect": "1.20.2",
    "mocha": "3.0.2",
    "vinyl-buffer": "1.0.0",
    "vinyl-source-stream": "1.1.0",
    "yargs": "5.0.0"
  },
  "dependencies": {
    "analytics-node": "3.2.0",
    "autoprefixer": "7.2.3",
    "babel-cli": "6.26.0",
    "babel-core": "6.14.0",
    "babel-plugin-react-transform": "2.0.2",
    "babel-plugin-transform-runtime": "6.12.0",
    "babel-preset-es2015": "6.14.0",
    "babel-preset-react": "6.11.1",
    "babelify": "7.3.0",
    "bluebird": "3.5.1",
    "body-parser": "1.18.2",
    "bootstrap": "git://github.com/tradecoffee/bootstrap.git#v3.3.7-custom",
    "braintree-web": "3.26.0",
    "browserify": "13.1.0",
    "compression": "1.7.2",
    "connect-redis": "3.3.2",
    "cookie-parser": "1.4.3",
    "cors": "2.8.4",
    "create-react-class": "15.6.3",
    "envify": "4.1.0",
    "express": "4.14.0",
    "express-http-proxy": "1.0.0",
    "express-session": "1.15.6",
    "font-awesome": "4.6.3",
    "helmet": "3.9.0",
    "heroku-ssl-redirect": "0.0.4",
    "honeybadger": "1.2.1",
    "honeybadger-js": "0.5.5",
    "jquery": "1.9.1",
    "jsonwebtoken": "8.2.0",
    "lodash": "4.17.4",
    "newrelic": "3.3.0",
    "node-sass": "4.1.1",
    "npm-run-all": "3.0.0",
    "onchange": "3.3.0",
    "passport": "0.2.0",
    "passport-http": "0.2.2",
    "postcss": "6.0.14",
    "react": "15.6.2",
    "react-autosuggest": "9.3.2",
    "react-bootstrap": "0.32.1",
    "react-dom": "15.6.2",
    "request": "2.83.0",
    "request-promise": "4.2.2",
    "rimraf": "2.5.4",
    "forge-sha256": "git://github.com/tradecoffee/forge-sha256",
    "uglify-js": "3.2.2",
    "uglifyify": "4.0.5",
    "watchify": "3.11.0",
    "wolfy87-eventemitter": "5.2.4"
  }

1 个答案:

答案 0 :(得分:0)

将其导入

  import LazyLoad from 'react-lazy-load';

  var LazyLoad = require('react-lazy-load');