gpt4 book ai didi

css - 如何将 video.js 与 create-next-app nextjs 一起使用?

转载 作者:行者123 更新时间:2023-12-05 07:33:16 24 4
gpt4 key购买 nike

我正在尝试将 Video.js 与 create-next-app 结合使用,但我无法加载 video.js.css。这就是我的组件的样子。

import videojs from 'video.js'

import videoStyles from '../node_modules/video.js/dist/video-js.min.css'

export default class VideoPlayer extends React.Component {
componentDidMount() {
// instantiate Video.js
this.player = videojs(this.videoNode, this.props, function onPlayerReady() {
console.log('onPlayerReady', this)
});
}

// destroy player on unmount
componentWillUnmount() {
if (this.player) {
this.player.dispose()
}
}

// wrap the player in a div with a `data-vjs-player` attribute
// so videojs won't create additional wrapper in the DOM
// see https://github.com/videojs/video.js/pull/3856
render() {
return (
<div>
<div data-vjs-player>
<video ref={ node => this.videoNode = node } className="video-js"></video>
</div>
<style jsx>{videoStyles}</style>
</div>
)
}
}

我正在使用 styled-jsx/css loader加载外部 css 文件。

最佳答案

看next.js github example .它应该足以让您入门。

关于css - 如何将 video.js 与 create-next-app nextjs 一起使用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50713855/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com