我想知道我会怎么做;使用写在外部javascript文件中的函数,然后在ejs
中使用它。
这是代码;
<head>
<script src="https://code.jquery.com/jquery-3.3.1.js" integrity="sha256-2Kok7MbOyxpgUVvAk/HJ2jigOSYS2auK4Pfzbm7uH60=" crossorigin="anonymous"></script>
<script src="//gitcdn.link/repo/wintercounter/Protip/master/protip.min.js"></script>
<script src='/javascripts/index.js'></script>
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.3.1/css/all.css" integrity="sha384-mzrmE5qonljUremFsqc01SB46JvROS7bZs3IO2EmfFsd15uHvIt+Y8vEf7N7fWAU" crossorigin="anonymous">
<link rel="stylesheet" href="//gitcdn.link/repo/wintercounter/Protip/master/protip.min.css">
<link rel='stylesheet' href='/stylesheets/style.css'/>
<link href="https://fonts.googleapis.com/css?family=Work+Sans" rel="stylesheet">
</head>
<body>
<% include header %>
<section class='header-placeholder'></section>
<section class='game'>
<% items.forEach(function(item){ %>
<% hi(); %>
<% }); %>
</section>
<% include footer %>
</body>
我正在尝试像这样用hi()
编写的函数index.js
;
function hi(){
console.log('hello');
}
有什么方法可以访问此功能,或者我可以通过某种方式在ejs中使用该功能并从js访问它?