我正在使用这个库https://github.com/mattboldt/typed.js/。我已经在正文代码的末尾添加了所有脚本文件,但我仍然在控制台中收到错误。我的代码是:
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title>LUNA-NG</title>
<meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="apple-touch-icon" href="apple-touch-icon.png">
<link href="https://fonts.googleapis.com/css?family=Source+Sans+Pro:200,400,700,900' rel='stylesheet" type="text/css">
<link rel="stylesheet" href="css/bootstrap.min.css">
<link href="https://fonts.googleapis.com/css?family=Montserrat:100,200,300,400,500,600,700,800,900" rel="stylesheet">
<link rel="stylesheet" href="css/bootstrap-theme.min.css">
<link rel="stylesheet" href="css/fontAwesome.css">
<link rel="stylesheet" href="css/tooplate-style.css">
<link rel="stylesheet" href="node_modules/typed.js/assets/demos.css">
</head>
<body>
<span class="typed"></span>
<script src="js/vendor/jquery-1.11.2.min.js"></script>
<script src="js/vendor/bootstrap.min.js"></script>
<script src="js/plugins.js"></script>
<script src="js/main.js"></script>
<script src="node_modules/animejs/anime.min.js"></script>
<!-- Google Analytics: change UA-XXXXX-X to be your site's ID. -->
<script>
(function(b,o,i,l,e,r){b.GoogleAnalyticsObject=l;b[l]||(b[l]=
function(){(b[l].q=b[l].q||[]).push(arguments)});b[l].l=+new Date;
e=o.createElement(i);r=o.getElementsByTagName(i)[0];
e.src='//www.google-analytics.com/analytics.js';
r.parentNode.insertBefore(e,r)}(window,document,'script','ga'));
ga('create','UA-XXXXX-X','auto');ga('send','pageview');
</script>
<script type="text/javascript" src="jquery.interactive_3d.js"></script>
<script src="node_modules/typed.js/lib/typed.js"></script>
<script>
$(function() {
$(".typed").typed({
strings: ["Typed.js is a jQuery plugin that types.", "Enter in any string,", "and watch it type at the speed you've set,", "backspace what it's typed,", "and begin a new sentence for however many strings you've set."],
typeSpeed: 0
});
});
</script>
控制台:
Uncaught TypeError: $(...).typed is not a function
at HTMLDocument.<anonymous> ((index):259)
at j (jquery-1.11.2.min.js:2)
at Object.fireWith [as resolveWith] (jquery-1.11.2.min.js:2)
at Function.ready (jquery-1.11.2.min.js:2)
at HTMLDocument.J (jquery-1.11.2.min.js:2)
非常感谢这方面的任何帮助。提前谢谢。
答案 0 :(得分:1)
我正在使用cdn for typed.js库。现在工作正常。我正在给出正确的路径,即使我收到错误,所以我决定转向cdn。以下是我已经包含的脚本。谢谢您的回答
<script src="https://cdnjs.cloudflare.com/ajax/libs/typed.js/1.1.1/typed.min.js"></script>
答案 1 :(得分:0)
由于某些原因,可能会发生此错误: 1.您包含的jquery文件可能路径错误。 2. Jquery文件可能不止一次包含在页面上。
请检查以上几点,如果不起作用,我们可以进一步讨论。
答案 2 :(得分:0)
我认为正确的答案是从此路径重新安装typed.js。 我有相同的问题,我做了相同的解决方案,现在对我有用 https://cdnjs.cloudflare.com/ajax/libs/typed.js/1.1.1/typed.min.js