2

我正在尝试使用 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>

这可能真的很简单,但我现在无法弄清楚。你能帮助我吗?

4

2 回答 2

0

要重现此类问题,我们可以

1)“删除”角度脚本参考,或 2)将它放在我们模块之后的“后期”位置。

Try To Load scripts in the sequence below:-
app.Module
Controller
Interface
angular.js
angular.min.js
app.route
于 2015-06-05T10:38:30.157 回答
0

当我使用 cdn version(" https://cdn.bootcss.com/typed.js/1.1.4/typed.min.js") 时,它工作正常。但是当我尝试从 github 下载 typed.js 时,它给出了同样的错误。

为了解决这个问题,我访问了 cdn 链接并将页面复制到我的 typed.js 中。它解决了我的问题。

于 2018-03-21T18:23:20.197 回答