快捷导航

没有报错但是图片没有显示到网页上

//加载CSSrequire('normalize.css/normalize.css');require('styles/App.scss');import React from 'react';//获取图片相关数据const imageDatas = require('json-loader!../data/imageDatas.json');//利用自执行函数,将图片名信息转成图片URL路径信息ImageData = (function genImageURL(imageDataArr) {  for (var i = 0, j = imageDataArr.length; i < j; i++) {    var singleImageData = imageDataArr;    singleImageData.imageURL = require('../images/' + singleImageData.fileName);    imageDataArr = singleImageData;  }  return imageDataArr;})(ImageData);//单个图片组件class ImgFigure extends React.Component {  render() {    return (              
                  {this.props.data.title}

                  );  }}class GalleryAPP extends React.Component {  render() {    var controllerUnits = [],      imgFigures = [];    imageDatas.forEach(function (value) {      imgFigures.push(
);    });    return (                        {imgFigures}                          {controllerUnits}                  );  }}GalleryAPP.defaultProps = {};export default GalleryAPP;

免责声明:本内容仅代表回答者见解不代表本站观点,请谨慎对待。

版权声明:作者保留权利,不代表本站立场。

回复

使用道具 举报

参与会员1

Main.js?7cd4:13 Uncaught TypeError: Cannot read property 'fileName' of undefined
  at genImageURL (eval at  (app.js:2437), :35:80)
  at Object.eval (eval at  (app.js:2437), :39:2)
  at Object.eval (eval at  (app.js:2437), :119:27)
  at eval (eval at  (app.js:2437), :120:30)
  at Object. (app.js:2437)
  at __webpack_require__ (app.js:556)
  at fn (app.js:87)
  at Object.eval (eval at  (app.js:1051), :15:13)
  at Object.eval (eval at  (app.js:1051), :24:27)
  at eval (eval at  (app.js:1051), :25:30)
回复

使用道具 举报

可能感兴趣的问答

发新帖
  • 微信访问
  • 手机APP