相关疑难解决方法(0)

添加背景视频时 NextJS 抛出错误

我想添加背景视频,格式为mp4,但NextJS显示错误:

./public/video/ocean.mp4 1:0
Module parse failed: Unexpected character '' (1:0)
You may need an appropriate loader to handle this file type, currently 
no loaders are configured to process this file. See 
https://webpack.js.org/concepts#loaders
Run Code Online (Sandbox Code Playgroud)

(此二进制文件省略源代码)

import React, {useEffect, useRef} from "react"
import Layout from "../components/webSite/layout";
import backgroundVideo from "../public/video/ocean.mp4"

const Home = () => {
  const videoRef = useRef()

  useEffect(() => {
    setTimeout(()=>{
      videoRef.current.play()
    },5000)
  }, []);

  return <Layout title={"Home"}>
    <video
        ref={videoRef}
        controls
        width="250"
        loop
        muted
        style={{
          position: "relative",
          width: "100%",
          height: …
Run Code Online (Sandbox Code Playgroud)

background next.js

12
推荐指数
3
解决办法
1万
查看次数

标签 统计

background ×1

next.js ×1