jQuery.verto is not a constructor

2019-08-19 06:56发布

I'm using a Verto library in my Vue-CLI based project - I've copied all necessary files to my static folder and imported it directly as a files in my index.html file - something like this:

<script src="static/js/jquery.min.js"></script> // I've also tried with including jQuery in webpack config, but with the same result
<script src="static/js/jquery.json.min.js"></script>
<script src="static/js/jquery.verto.js"></script>
<script src="static/js/jquery.FSRTC.js"></script>
<script src="static/js/jquery.jsonrpcclient.js"></script>

And in my component's methods I have something like this:

connectAudio () {
  /* eslint-disable new-cap */
  const verto = new jQuery.verto({
  ...

But once I execute it, I receive an error: "TypeError: jQuery.verto is not a constructor"

Can someone help me with this?

1条回答
Explosion°爆炸
2楼-- · 2019-08-19 07:21

Make sure you're calling new jQuery.verto({}) inside the verto init callback as the docs suggest.

Example: $.verto.init({}, function(){ ... new jQuery.verto({...}) ... }).

Not sure if you're already doing it, I can't tell by the code snippet you shared.

查看更多
登录 后发表回答