Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/456.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 未捕获引用错误:在sp.runtime.js中未定义类型_Javascript_Jquery_Sharepoint_Sharepoint Apps_Officedev - Fatal编程技术网

Javascript 未捕获引用错误:在sp.runtime.js中未定义类型

Javascript 未捕获引用错误:在sp.runtime.js中未定义类型,javascript,jquery,sharepoint,sharepoint-apps,officedev,Javascript,Jquery,Sharepoint,Sharepoint Apps,Officedev,我试图使用OfficePNP中的分类选择器示例 我只想将一个字段绑定到一个托管元数据项 我得到的错误如下: 我的密码是: <head> <meta charset="utf-8" /> <title>Learning bootstrap</title> <meta name="viewport" content="width=device-width, initial-scale=1">

我试图使用OfficePNP中的分类选择器示例

我只想将一个字段绑定到一个托管元数据项

我得到的错误如下:

我的密码是:

<head>
    <meta charset="utf-8" />
    <title>Learning bootstrap</title>    
    <meta name="viewport" content="width=device-width, initial-scale=1">   

    <link href="../Content/bootstrap.min.css" rel="stylesheet" /> 
    <link href="../Content/bootstrap-theme.min.css" rel="stylesheet" />
    <link rel="Stylesheet" type="text/css" href="../Content/taxonomypickercontrol.css" />
    <script src="../Scripts/jquery-2.1.1.min.js"></script>
    <script type="text/javascript" src="/_layouts/15/sp.runtime.js"></script>
    <script type="text/javascript" src="/_layouts/15/sp.js"></script>

    <script src="../Scripts/app.js" type="text/javascript"></script>
    <script src="../Scripts/taxonomypickercontrol.js" type="text/javascript"></script>
</head>


body>
    <div id="divSPChrome"></div>
    <div class="container">      
        <div class="row">
            <div class="col-md-8">
                <h2>Create project site</h2>
                <form class="form-horizontal" role="form">
                    <div class="form-group">
                        <label for="inputEmail3" class="col-sm-2 control-label">Project name</label>
                        <div class="col-sm-10">
                            <input type="text" class="form-control" id="inputEmail3" placeholder="Project name">
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="inputPassword3" class="col-sm-2 control-label">Domain</label>
                        <div class="col-sm-10">
                            <input type="text" class="form-control" id="inputPassword3" placeholder="Domain">
                            <div class="ms-core-form-line" style="margin-bottom: 0px;">
                               <input type="hidden" id="taxPickerContinent" />

                            </div>
                        </div>
                    </div>

学习引导
正文>
创建项目站点
项目名称
领域
正如你所看到的,我有一个隐藏的字段。 我的App.js文件是:

// variable used for cross site CSOM calls
var context;
// variable to hold index of intialized taxPicker controls
var taxPickerIndex = {};

//Wait for the page to load
$(document).ready(function () {

    //Get the URI decoded SharePoint site url from the SPHostUrl parameter.
    var spHostUrl = decodeURIComponent(getQueryStringParameter('SPHostUrl'));
    var appWebUrl = decodeURIComponent(getQueryStringParameter('SPAppWebUrl'));
    var spLanguage = decodeURIComponent(getQueryStringParameter('SPLanguage'));

    //Build absolute path to the layouts root with the spHostUrl
    var layoutsRoot = spHostUrl + '/_layouts/15/';

    //load all appropriate scripts for the page to function
    $.getScript(layoutsRoot + 'SP.Runtime.js',
        function () {
            $.getScript(layoutsRoot + 'SP.js',
                function () {
                    //Load the SP.UI.Controls.js file to render the App Chrome
                    $.getScript(layoutsRoot + 'SP.UI.Controls.js', renderSPChrome);

                    //load scripts for cross site calls (needed to use the people picker control in an IFrame)
                    $.getScript(layoutsRoot + 'SP.RequestExecutor.js', function () {
                        context = new SP.ClientContext(appWebUrl);
                        var factory = new SP.ProxyWebRequestExecutorFactory(appWebUrl);
                        context.set_webRequestExecutorFactory(factory);
                    });

                    //load scripts for calling taxonomy APIs
                    $.getScript(layoutsRoot + 'init.js',
                        function () {
                            $.getScript(layoutsRoot + 'sp.taxonomy.js',
                                function () {
                                    //bind the taxonomy picker to the default keywords termset
                                    //$('#taxPickerKeywords').taxpicker({ isMulti: true, allowFillIn: true, useKeywords: true }, context);

                                    $('#taxPickerContinent').taxpicker({ isMulti: false, allowFillIn: false, useKeywords: false, termSetId: "51f18389-f28a-4961-a903-ee535f7c620d", levelToShowTerms: 1 }, context, initializeCountryTaxPicker);
                                    taxPickerIndex["#taxPickerContinent"] = 0;
                                });
                        });
                });
        });
});

function initializeCountryTaxPicker() {
    //if (this._selectedTerms.length > 0) {
    //    $('#taxPickerCountry').taxpicker({ isMulti: false, allowFillIn: false, useKeywords: false, termSetId: "0cc96f04-d32c-41e7-995f-0401c1f4fda8", filterTermId: this._selectedTerms[0].Id, levelToShowTerms: 2, useTermSetasRootNode: false }, context, initializeRegionTaxPicker);
    //    taxPickerIndex["#taxPickerCountry"] = 4;
    //}
}

function initializeRegionTaxPicker() {
    //if (this._selectedTerms.length > 0) {
    //    $('#taxPickerRegion').taxpicker({ isMulti: false, allowFillIn: false, useKeywords: false, termSetId: "0cc96f04-d32c-41e7-995f-0401c1f4fda8", filterTermId: this._selectedTerms[0].Id, levelToShowTerms: 3, useTermSetasRootNode: false }, context);
    //    taxPickerIndex["#taxPickerRegion"] = 5;
    //}
}

function getValue(propertyName) {
    if (taxPickerIndex != null) {
        return taxPickerIndex[propertyName];
    }
};

//function to get a parameter value by a specific key
function getQueryStringParameter(urlParameterKey) {
    var params = document.URL.split('?')[1].split('&');
    var strParams = '';
    for (var i = 0; i < params.length; i = i + 1) {
        var singleParam = params[i].split('=');
        if (singleParam[0] == urlParameterKey)
            return singleParam[1];
    }
}

function chromeLoaded() {
    $('body').show();
}

//function callback to render chrome after SP.UI.Controls.js loads
function renderSPChrome() {
    var icon = decodeURIComponent(getQueryStringParameter('SPHostLogoUrl'));

    //Set the chrome options for launching Help, Account, and Contact pages
    var options = {
        'appTitle': document.title,
        'appIconUrl': icon,
        'onCssLoaded': 'chromeLoaded()'
    };

    //Load the Chrome Control in the divSPChrome element of the page
    var chromeNavigation = new SP.UI.Controls.Navigation('divSPChrome', options);
    chromeNavigation.setVisible(true);
}
//用于跨站点CSOM调用的变量
var语境;
//保存初始taxPicker控件索引的变量
var-taxPickerIndex={};
//等待页面加载
$(文档).ready(函数(){
//从SPHostUrl参数获取URI解码的SharePoint网站url。
var spHostUrl=decodeURIComponent(getQueryStringParameter('spHostUrl');
var appWebUrl=decodeURIComponent(getQueryStringParameter('SPAppWebUrl');
var spLanguage=decodeURIComponent(getQueryStringParameter('spLanguage');
//使用spHostUrl构建布局根目录的绝对路径
var layoutsRoot=spHostUrl+'/_layouts/15/';
//加载页面运行所需的所有适当脚本
$.getScript(layoutsRoot+'SP.Runtime.js',
函数(){
$.getScript(layoutsRoot+SP.js),
函数(){
//加载SP.UI.Controls.js文件以呈现应用程序Chrome
$.getScript(layoutsRoot+'SP.UI.Controls.js',renderSPChrome);
//为跨站点调用加载脚本(需要在IFrame中使用人员选择器控件)
$.getScript(layoutsRoot+'SP.RequestExecutor.js',函数(){
context=new SP.ClientContext(appWebUrl);
var factory=new SP.ProxyWebRequestExecutorFactory(appWebUrl);
context.set_webRequestExecutorFactory(工厂);
});
//加载用于调用分类API的脚本
$.getScript(layoutsRoot+'init.js',
函数(){
$.getScript(layoutsRoot+'sp.taxonomy.js',
函数(){
//将分类选择器绑定到默认关键字术语集
//$('#taxPickerKeywords').taxpicker({isMulti:true,allowFillIn:true,useKeywords:true},context);
$(#taxPickerContinent')。taxpicker({isMulti:false,allowFillIn:false,useKeywords:false,termSetId:“51f18389-f28a-4961-a903-ee535f7c620d”,levelToShowTerms:1},上下文,初始化CountryTaxPicker);
taxPickerIndex[“#taxPickerContinent”]=0;
});
});
});
});
});
函数初始化CountryTaxPicker(){
//如果(此项。\u选择的项长度>0){
//$(“#taxPickerCountry”).taxpicker({isMulti:false,allowFillIn:false,useKeywords:false,termSetId:“0C96F04-d32c-41e7-995f-0401c1f4fda8”,FilterTerms:this.\u selectedTerms[0]。Id,levelToShowTerms:2,useTermSetasRootNode:false},上下文,InitializeRegionExpicker);
//taxPickerIndex[“#taxPickerCountry”]=4;
//}
}
函数initializeRegionTaxPicker(){
//如果(此项。\u选择的项长度>0){
//$(“#taxPickerRegion”).taxpicker({isMulti:false,allowFillIn:false,useKeywords:false,termSetId:“0C96F04-d32c-41e7-995f-0401c1f4fda8”,FilterTerm:this.\u selectedTerms[0]。Id,levelToShowTerms:3,useTermSetasRootNode:false,上下文);
//taxPickerIndex[“#taxPickerRegion”]=5;
//}
}
函数getValue(propertyName){
如果(taxPickerIndex!=null){
返回taxPickerIndex[propertyName];
}
};
//函数通过特定键获取参数值
函数getQueryStringParameter(urlParameterKey){
var params=document.URL.split('?')[1].split('&');
var strParams='';
对于(变量i=0;i
加载SP.Runtime.jsSP.js两次。一旦在头部和文件准备就绪。尝试删除其中一个,但错误可能是另一个。我在404之前看到更多错误。

您缺少scriptmanager。把它放在上面


当您在html页面中工作时,只需在加载jquery后尝试引用它

<script src="https://ajax.aspnetcdn.com/ajax/4.0/MicrosoftAjax.js" type="text/javascript"></script> 


这可能是由于您注册脚本的顺序造成的。引用的库应该在使用它们的脚本之前注册。在浏览器中查看页面最简单,您将看到页面加载的顺序

类型
在MicrosoftAjax.js文件中定义。您可以通过以下方式访问它<
<script src="https://ajax.aspnetcdn.com/ajax/4.0/MicrosoftAjax.js" type="text/javascript"></script> 
<script type="text/javascript" src="//ajax.aspnetcdn.com/ajax/4.0/1/MicrosoftAjax.js"></script>