我需要从 ascx 控件访问共享点样式库中的 css 和 javascript 文件。我将自定义 css 和 javascript 文件存储在样式库中,并在 ascx 中添加了以下代码。但问题是 sharepoint没有从下面给定的路径中识别 javascript 文件。
ascx 中的代码
<SharePoint:CssLink runat="server" ID="MenuCSSLink" Version="4" ></SharePoint:CssLink>
<SharePoint:CssRegistration Name="/Style Library/en-us/Core Styles/Style.css" EnableCssTheming="True" ID="css" runat="server"></SharePoint:CssRegistration>
<SharePoint:ScriptLink id="ScriptLinkMenu1" runat="server" Name="~SiteCollection/Style Library/en-us/Core Styles/JS/script1.js " ></SharePoint:ScriptLink>
<SharePoint:ScriptLink id="ScriptLinkMenu2" runat="server" Name="~SiteCollection/Style Library/en-us/Core Styles/JS/script2.min.js " ></SharePoint:ScriptLink>
<SharePoint:ScriptLink id="ScriptLinkMenu3" runat="server" Name="~SiteCollection/Style Library/en-us/Core Styles/JS/script3.js " ></SharePoint:ScriptLink>
<SharePoint:ScriptLink id="ScriptMenu6" runat="server" Name="~SiteCollection/Style Library/en-us/Core Styles/JS/script4.js " ></SharePoint:ScriptLink>
我用 IE 开发者工具(F12)测试了页面,发现 css 可以正常渲染,但 js 不行。我将 Java 脚本保存在样式库根目录中并进行了测试。这个也行不通