视频反应组件显示错误

时间:2018-05-29 07:07:12

标签: javascript reactjs webpack react-component video-reactjs

我在我的项目中使用react-video-player组件&在页面中使用它时,它显示以下错误。我附上了截图。

enter image description here

有人可以帮忙吗?我有以下代码:

import React, { Component } from "react";
import "video-react/dist/video-react.css";
import { Player } from 'video-react';

class VideoPlayer extends Component {
  render() {
    return(
      <Player
          playsInline
          poster="/assets/poster.png"
          src="https://media.w3.org/2010/05/sintel/trailer_hd.mp4"
      />
    );
  }
}
export default VideoPlayer;

并且我还有以下配置文件可能有助于您理解错误。

/ * webpack.config.js * /

/* eslint comma-dangle: ["error",
 {"functions": "never", "arrays": "only-multiline", "objects":
 "only-multiline"} ] */

const webpack = require('webpack');
const pathLib = require('path');

const devBuild = process.env.NODE_ENV !== 'production';

const config = {
  entry: [
    'es5-shim/es5-shim',
    'es5-shim/es5-sham',
    'babel-polyfill',
    './app/bundles/HelloWorld/startup/registration',
  ],

  output: {
    filename: 'webpack-bundle.js',
    path: pathLib.resolve(__dirname, '../app/assets/webpack'),
  },

  resolve: {
    extensions: ['.js', '.jsx'],
  },
  plugins: [
    new webpack.EnvironmentPlugin({ NODE_ENV: 'development' }),
  ],
  module: {
    rules: [
      {
        test: require.resolve('react'),
        use: {
          loader: 'imports-loader',
          options: {
            shim: 'es5-shim/es5-shim',
            sham: 'es5-shim/es5-sham',
          }
        },
      },
      {
        test: /\.jsx?$/,
        use: 'babel-loader',
        exclude: /node_modules/,
      },
    ],
  },
};

module.exports = config;

if (devBuild) {
  console.log('Webpack dev build for Rails'); // eslint-disable-line no-console
  module.exports.devtool = 'eval-source-map';
} else {
  console.log('Webpack production build for Rails'); // eslint-disable-line no-console
}

2 个答案:

答案 0 :(得分:0)

你可能需要webpack中的css加载器

{
      test: /\.css$/,  
      include: /node_modules/,  
      loaders: ['style-loader', 'css-loader'],
 }

答案 1 :(得分:0)

安装react视频时在命令行中使用命令--force