Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
3.0k views
in Technique[技术] by (71.8m points)

页面通过script标签引入了html2canvas,却报错html2canvas is not defined

如题所示,网页通过script标签引入了html2canvas,但在使用时却仍然报错“Uncaught ReferenceError: html2canvas is not defined”。

网页代码:

<script src="/static/plugs/div2img/html2canvas.min.js"></script>

错误截图:
image

希望社区中精通前端的朋友帮忙指点指点。不胜感激~

感谢1楼的回复,补充一下,排除路径错误导致的加载失败。
image


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

原因可能有很多,比如

1、路径错误,html2canvas.min.js并没有成功加载
2、代码运行发生在html2canvas.min.js加载成功之前
3、你的这个html2canvas.min.js文件中并没有把html2canvas赋值到全局

现在比较怀疑第一条,你看下network里资源有没有加载成功


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...