gpt4 book ai didi

jquery - asp.net mvc 让 jQuery 在 View 中工作

转载 作者:行者123 更新时间:2023-12-01 03:39:50 25 4
gpt4 key购买 nike

我试图让 jQuery 在我的 View 中工作,但我无法显示一个简单的警报框!

我的 _Layout 页面在结束“body”标记之前定义了默认包:

 @Scripts.Render("~/bundles/jquery")
@Scripts.Render("~/bundles/bootstrap")
@RenderSection("scripts", required: false)
</body>

在我的 View 顶部有一个脚本部分:

@section scripts {
<script type=”text/javascript”>
$(function() {
alert("hello");
});
</script>
}

渲染页面的源代码在结束“body”标记之前显示了这一点:

   <script src="/bundles/jquery?v=Aj1GKhwLcrKGfvkl6W3KyVVaqQJQ2zhPCS3xQ5-_xuE1"></script>

<script src="/bundles/bootstrap?v=2Fz3B0iizV2NnnamQFrx-NbYJNTFeBJ2GM05SilbtQU1"> </script>


<script type=”text/javascript”>
$(function() {
alert("hello");
});
</script>

为什么我没有看到警报消息?

最佳答案

从这里删除智能双引号或者我应该说大引号 <script type=”text/javascript”> :

@section scripts {
<script type="text/javascript">
$(function() {
alert("hello");
});
</script>
}
<小时/>

" 不同双引号。

关于jquery - asp.net mvc 让 jQuery 在 View 中工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24140375/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com