0
我爲Angular使用了dotnet SPA模板。我如何在我的組件中使用jQuery?當我在我的組件中執行以下操作時,我沒有收到警報:通過dotnet的SPA模板使用jQuery與Angular 2
<script>
$(document).ready(function() {
alert("test");
});
</script>
我爲Angular使用了dotnet SPA模板。我如何在我的組件中使用jQuery?當我在我的組件中執行以下操作時,我沒有收到警報:通過dotnet的SPA模板使用jQuery與Angular 2
<script>
$(document).ready(function() {
alert("test");
});
</script>
是否包含jQuery和angular的庫? 看來你沒有把它包含到你的頭標籤中。
<html>
<head>
<script src="https://code.jquery.com/jquery-3.2.1.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/2.0.0-beta.9/angular2.min.js"></script>
<script>
$(document).ready(function(){
alert("Hello World");
});
</script>
</head>
<body>
<h3>Hello WORLD!</h3>
</body>
</html>
我已經將它包含在_Layout.cshtml文件中,但它仍然不起作用。 –
你看看開發工具日誌嗎?知道是否有一些錯誤指出? – Nel
控制檯沒有錯誤。它是Angular2,我使用的是由dotnet提供的SPA模板,所以腳本的引用是在其他地方完成的,我不太確定它在哪裏! –