1

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

在此处输入图像描述

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

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
}
4

2 回答 2

1

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

于 2021-07-12T20:23:24.067 回答
0

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

{
      test: /\.css$/,  
      include: /node_modules/,  
      loaders: ['style-loader', 'css-loader'],
 }
于 2018-05-29T07:22:35.243 回答