【发布时间】:2018-10-19 18:09:33
【问题描述】:
这是我的代码:
// And my javascript file verbatims.js :
class Verbatims {
list() {
return ["c'est super", "j'aime pas", "ça marche bien"];
}
}
module.exports = Verbatims;
<!DOCTYPE html>
<html lang="fr">
<head>
<meta charset="utf-8">
<meta content="X-Content-Type-Options: nosniff">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/1.0.18/vue.min.js"></script>
<script src="/src/verbatims.js" type="application/javascript"></script>
<title>My Project</title>
</head>
<body>
<div id="PRISME_data">
Le nombre de requête est de : {{ nb_request }}<br>
<button v-on:click="change">Change value</button>
<button v-on:click="stop">Arrêter</button>
</div>
<script>
let app = new Vue({
el:'#PRISME_data',
data: {
nb_request: "toto",
ite: 0
},
methods: {
change: function() {
changeNbRequest()
},
stop: function() {
clearInterval()
}
}
});
changeNbRequest = function() {
var timer = setInterval(function() {
let verbatim = new Verbatims().list()[ite];
}, 5000);
}
</script>
</body>
</html>
当我尝试用我的节点服务器显示我的页面时,我遇到了这个错误:
Uncaught ReferenceError: Verbatims is not defined at index:45
在这条线上:let verbatim = new Verbatims().list()[ite];
我不明白为什么,我尝试了很多东西但没有任何效果!你有什么想法吗?
谢谢你:)
【问题讨论】:
-
module.exports = Verbatims;这是第45行的内容吗? -
不抱歉,我忘了准确!错误在这一行:
let verbatim = new Verbatims().list()[ite]; -
您是否确认(使用开发人员工具的“网络”选项卡)
verbatims.js正在成功加载?在您引用的错误之前,控制台上是否有任何先前的错误? -
verbatims.js 加载成功,在此之前控制台上没有错误。
标签: javascript html node.js vue.js