我无法从文件夹中引用相关js文件。signalrwwwroot我需要参考的路径是:wwwroot/lib/@aspnet/signalr/dist/browser/signalr.jswwwroot/js/chat.js这是我的观点:@page<div class="container"> <div class="row"> </div> <div class="row"> <div class="col-6"> </div> <div class="col-6"> User..........<input type="text" id="userInput" /> <br /> Message...<input type="text" id="messageInput" /> <input type="button" id="sendButton" value="Send Message" /> </div> </div> <div class="row"> <div class="col-12"> <hr /> </div> </div> <div class="row"> <div class="col-6"> </div> <div class="col-6"> <ul id="messagesList"></ul> </div> </div></div><script src="~/wwwroot/lib/@@AspNetCore/signalr/dist/browser/signalr.js"></script><script src="~/wwwroot/js/chat.js"></script>我在浏览器中收到 404:http://localhost:5005/wwwroot/lib/@AspNetCore/signalr/dist/browser/signalr.js 404(未找到)http://localhost:5005/wwwroot/js/chat.js net::ERR_ABORTED 404(未找到)更新更改脚本路径后,我在浏览器中遇到了这些错误:http://localhost:5005/lib/@AspNetCore/signalr/dist/browser/signalr.js net::ERR_ABORTED 404(未找到)未捕获的 ReferenceError:signalR 未在 chat.js:3 中定义chat.js 第 3 行:var connection = new signalR.HubConnectionBuilder().withUrl("/chatHub").build();它下面有红色波浪线。
1 回答
肥皂起泡泡
TA贡献1829条经验 获得超6个赞
<script src="~/wwwroot/lib/@@AspNetCore/signalr/dist/browser/signalr.js"></script>
<script src="~/wwwroot/js/chat.js"></script>
换成这个
@section Scripts {
<script src="~/lib/@@AspNetCore/signalr/dist/browser/signalr.js"></script>
<script src="~/js/chat.js"></script>
}
添加回答
举报
0/150
提交
取消