问答

vue3+ts 在index.html的head引入了js文件,但是在使用的时候报错

作者:admin 2021-05-07 我要评论

在index.html引入了腾讯播放器的cdn head meta charset="utf-8" script src="/uploads/allimg/210507/0Z12C137-0.jpg" charset="utf-8"/script link href="https...

在说正事之前,我要推荐一个福利:你还在原价购买阿里云、腾讯云、华为云服务器吗?那太亏啦!来这里,新购、升级、续费都打折,能够为您省60%的钱呢!2核4G企业级云服务器低至69元/年,点击进去看看吧>>>)

在index.html引入了腾讯播放器的cdn

  <head>
    <meta charset="utf-8">
    <script src="/uploads/allimg/210507/0Z12C137-0.jpg" charset="utf-8"></script>
    <link href="https://cloudcache.tencent-cloud.com/open/qcloud/video/tcplayer/tcplayer.css" rel="stylesheet">
    <!--如果需要在 Chrome 和 Firefox 等现代浏览器中通过 H5 播放 HLS 格式的视频,需要在 tcplayer.v4.1.min.js 之前引入 hls.min.0.13.2m.js。-->
    <script src="/uploads/allimg/210507/0Z1263a6-1.jpg"></script>
    <!--播放器脚本文件-->
    <script src="/uploads/allimg/210507/0Z1261609-2.jpg"></script>
    <title><%= htmlWebpackPlugin.options.title %></title>
  </head>

在使用的时候提示
image.png
这种情况如何处理

###

TS 不知道你有个通过 CDN 引用的全局变量啊,所以报错了。

你自己声明个全局变量告诉 TS 就好了:

// tcplayer.d.ts
declare function TCPlayer(...args: any[]): any;

版权声明:本文转载自网络,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。本站转载出于传播更多优秀技术知识之目的,如有侵权请联系QQ/微信:153890879删除

相关文章
  • vue3+ts 在index.html的head引入了js文

    vue3+ts 在index.html的head引入了js文

  • php-fpm处理时间很快,但nginx upstrea

    php-fpm处理时间很快,但nginx upstrea

  • XLSX.write 具体是做什么的呢?

    XLSX.write 具体是做什么的呢?

  • dockerfile推送could not push images

    dockerfile推送could not push images

腾讯云代理商
海外云服务器