为了账号安全,请及时绑定邮箱和手机立即绑定

视图不会在 MVC ASP.NET 呈现 CSS 和 Javascript

视图不会在 MVC ASP.NET 呈现 CSS 和 Javascript

九州编程 2022-08-27 15:03:36
我从事一个 ASP.net MVC项目,我有一个包含共享布局中某些部分的视图,我有三个共享布局视图,其中一个包含CSS文件,第二个包含Java脚本文件,第三个包含HTML代码,我用于将它们设置为视图的一部分。@RenderPage我的观点包含://html code@RenderPage("~/Views/Shared/_CssPage.cshtml")//html code@RenderPage("~/Views/Shared/_LeftSideBar.cshtml")//html code@RenderPage("~/Views/Shared/_JsPage.cshtml")_CssPage.cshtml :  <!-- Favicon--><link rel="icon" href="favicon.ico" type="image/x-icon"><!-- Google Fonts --><link href="https://fonts.googleapis.com/css?family=Roboto:400,700&subset=latin,cyrillic-ext" rel="stylesheet" type="text/css"><link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet" type="text/css"><!-- Bootstrap Core Css --><link href="plugins/bootstrap/css/bootstrap.css" rel="stylesheet"><!-- Waves Effect Css --><link href="plugins/node-waves/waves.css" rel="stylesheet" /><!-- Animation Css --><link href="plugins/animate-css/animate.css" rel="stylesheet" /><!-- Morris Chart Css--><link href="plugins/morrisjs/morris.css" rel="stylesheet" /><!-- Custom Css --><link href="css/style.css" rel="stylesheet"><!-- AdminBSB Themes. You can choose a theme from css/themes instead of get all themes --><link href="css/themes/all-themes.css" rel="stylesheet" />_LeftSideBar.cshtml :     <!-- Left Sidebar --><aside id="leftsidebar" class="sidebar">    <!-- User Info -->    <div class="user-info">        <div class="image">            <img src="images/user.png" width="48" height="48" alt="User" />        </div>
查看完整描述

1 回答

?
天涯尽头无女友

TA贡献1831条经验 获得超9个赞

我认为CSS和JS文件的路径需要在链接之前添加。/

例:

原始路径为

<link href="plugins/morrisjs/morris.css" rel="stylesheet" />

您需要在链接之前添加,如下所示:slash

<link href="/plugins/morrisjs/morris.css" rel="stylesheet" />

希望这对你有所帮助。


查看完整回答
反对 回复 2022-08-27
  • 1 回答
  • 0 关注
  • 129 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号