代码之家  ›  专栏  ›  技术社区  ›  Subhojit

视频反应组件显示错误

  •  0
  • Subhojit  · 技术社区  · 6 年前

    我在项目中使用的是React视频播放器组件,而在页面中使用时,它显示以下错误。我附上了截图。

    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;
    

    另外,我还有以下配置文件可以帮助您理解错误。

    /* 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
    }
    
    1 回复  |  直到 6 年前
        1
  •  0
  •   Leo Odishvili    6 年前

    在Webpack中可能需要CSS加载器

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