0

我的加载顺序有问题

<script type="text/javascript" src="/_layouts/15/sp.js"></script>
<script type="text/javascript" src="/_layouts/15/sp.runtime.js"></script>

在我的页面上

这是我的母版页上的整个头部部分。

<head runat="server">
    <meta name="GENERATOR" content="Microsoft SharePoint" />
    <meta http-equiv="Content-type" content="text/html; charset=utf-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=10"/>
    <meta http-equiv="Expires" content="0" />
    <SharePoint:SPPinnedSiteTile runat="server" TileUrl="/_layouts/15/images/SharePointMetroAppTile.png" TileColor="#0072C6" />
    <SharePoint:RobotsMetaTag runat="server"/>
    <SharePoint:PageTitle runat="server">
        <asp:ContentPlaceHolder id="PlaceHolderPageTitle" runat="server">
            <SharePoint:ProjectProperty Property="Title" runat="server" />
        </asp:ContentPlaceHolder>
    </SharePoint:PageTitle>
    <SharePoint:SPShortcutIcon runat="server" IconUrl="/_layouts/15/images/favicon.ico?rev=23" />
    <SharePoint:StartScript runat="server" />
    <SharePoint:CssLink runat="server" Version="15"/>
    <SharePoint:CacheManifestLink runat="server"/>
    <SharePoint:ScriptLink language="javascript" name="core.js" OnDemand="true" runat="server" Localizable="false" />
    <SharePoint:ScriptLink language="javascript" name="menu.js" OnDemand="true" runat="server" Localizable="false" />
    <SharePoint:ScriptLink language="javascript" name="callout.js" OnDemand="true" runat="server" Localizable="false" />
    <SharePoint:ScriptLink language="javascript" name="sharing.js" OnDemand="true" runat="server" Localizable="false" />
    <SharePoint:ScriptLink language="javascript" name="suitelinks.js" OnDemand="true" runat="server" Localizable="false" />
    <SharePoint:CustomJSUrl runat="server" />
    <SharePoint:SoapDiscoveryLink runat="server" />
    <SharePoint:AjaxDelta id="DeltaPlaceHolderAdditionalPageHead" Container="false" runat="server">
        <asp:ContentPlaceHolder id="PlaceHolderAdditionalPageHead" runat="server" />
        <SharePoint:DelegateControl runat="server" ControlId="AdditionalPageHead" AllowMultipleControls="true" />
        <asp:ContentPlaceHolder id="PlaceHolderBodyAreaClass" runat="server" />
    </SharePoint:AjaxDelta>
    <SharePoint:CssRegistration Name="Themable/corev15.css" runat="server" />
    <script type="text/javascript" src="/_layouts/15/sp.js"></script>
    <script type="text/javascript" src="/_layouts/15/sp.runtime.js"></script>


    <SharePoint:ScriptLink ID="ScriptLink1" runat="server" Name="~sitecollection/_catalogs/masterpage/Resources/js/jquery-1.11.0.min.js" Language="javascript" />
    <SharePoint:ScriptLink ID="ScriptLink3" runat="server" Name="~sitecollection/_catalogs/masterpage/Resources/js/global.js" Language="javascript" />
    <link rel="stylesheet" type="text/css" href="Resources/css/quack_1200.css" />
    <link rel="stylesheet" type="text/css" href="Resources/css/main.css" />
</head>

以下顺序会破坏我的代码(当我尝试使用 sp 上下文时):

<script type="text/javascript" src="/_layouts/15/sp.js"></script>
    <script type="text/javascript" src="/_layouts/15/sp.runtime.js"></script>

在此处输入图像描述

但是,如果我像这样切换脚本的顺序,我不会收到上一个错误,但是如果我尝试转到列表并单击“编辑”按钮,则会收到以下错误。

<script type="text/javascript" src="/_layouts/15/sp.runtime.js"></script>
    <script type="text/javascript" src="/_layouts/15/sp.js"></script>

在此处输入图像描述

在此处输入图像描述

对于这个令人困惑的问题的任何帮助将不胜感激。

4

1 回答 1

3

使用脚本标签:

<Sharepoint:ScriptLink runat="server" Name="SP.js" Localizable="false"  ID="s1" LoadAfterUI="true"/>
<Sharepoint:ScriptLink runat="server" Name="SP.Runtime.js" Localizable="false"  ID="s2" LoadAfterUI="true"/>

它可能会解决您的问题。

于 2014-05-19T04:58:01.743 回答