Video.js sets the Chinese language package in the vue project, and the error videojs is not defined is reported. Solution

When using video.js in a vue project, Chinese culture is required, but the solution online is not easy to find, so I will record it here.

Wrong steps:

  1. According to the online tutorial, find the Chinese package in node_modules/video.js/dist/lang/zh-CN.js
  2. import 'video.js/dist/lang/zh-CN.js
  3. Configure it to Chinese in settings:language:“zh-CN”
  4. Error: videojs is not defined

Solution:
1. Find this /zh-CN.js and add a sentence in it: import videojs from "video.js"
Disadvantages: This project involves multiple people cooperating. If others do not modify the plug-in synchronously, errors will still be reported, which is not conducive to project maintenance, so this solution is abandoned.

2. Just use zh-CN.json, it is effective through personal testing

  1. import videojs from "video.js"
  2. import "video.js/dist/video-js.css"
  3. import video_zhCN from 'video.js/dist/lang/zh-CN.json'
  4. videojs.addLanguage('zh-CN', video_zhCN)
  5. Configure it to Chinese in settings:language:“zh-CN”

Guess you like

Origin blog.csdn.net/qq_35696889/article/details/129585912