我正在尝试使用Typed.js库,但它似乎不起作用。它在控制台中显示以下错误消息:
Uncaught TypeError: undefined is not a function控制台中的引用是对以下行的引用:
$("#typed").typed({这个错误似乎表明我没有包含jQuery,但我确实包含了。
<!-- TYPED -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="js/typed.js"></script>
<script>
$(function(){
$("#typed").typed({
strings: ["Typed.js is a <strong>jQuery</strong> plugin.", "It <em>types</em> out sentences.", "And then deletes them.", "Try it out!"],
typeSpeed: 30,
backDelay: 500,
loop: false,
contentType: 'html', // or text
// defaults to false for infinite loop
loopCount: false,
callback: function(){ foo(); },
resetCallback: function() { newTyped(); }
});
$(".reset").click(function(){
$("#typed").typed('reset');
});
});
function newTyped(){ /* A new typed object */ }
function foo(){ console.log("Callback"); }
html:
<div class="col-lg-8 col-lg-offset-2 col-md-10 col-md-offset-1">
<div class="post-heading">
<h1>Baresso og Starbucks</h1>
<h2 class="subheading element">Så mange kalorier smider de rundt</h2>
<h2 class="element" id="typed">hej</h2>
<span class="meta">Posted by <a href="https://www.linkedin.com/profile/view?id=176878997&trk=nav_responsive_tab_profile">Kristoffer Andreasen</a> on November 24, 2014</span>
</div>这可能真的很简单,但我现在就是想不通。你能帮帮我吗?
发布于 2015-06-05 18:38:30
要重现这类问题,我们可以
1)“删除”angular脚本引用,或者2)把它放在最“晚”的位置,在我们的模块之后。
Try To Load scripts in the sequence below:-
app.Module
Controller
Interface
angular.js
angular.min.js
app.route发布于 2018-03-22 02:23:20
当我使用cdn版本(“https://cdn.bootcss.com/typed.js/1.1.4/typed.min.js”)时,它工作得很好。但是当我尝试从github下载typed.js时,它给出了同样的错误。
为了解决这个问题,我转到cdn链接并将页面复制到我的typed.js。它解决了我的问题。
https://stackoverflow.com/questions/28002267
复制相似问题