SPFx Web部件未在IE 11中加载

时间:2018-12-10 08:01:09

标签: javascript sharepoint knockout.js internet-explorer-11 spfx

我有一个带有Knockout框架的SPFx Web部件。它是为本地SharePoint(V1.1.0)开发的。在SharePoint库中部署了所有资产。应用程序在Chrome中运行正常。但是在IE中,Web部件未加载到页面中。即使我没有任何控制台日志/错误。如果在开发人员控制台打开的情况下刷新页面,则该页面有效。

即使从捆绑的JS中删除了控制台日志,我也删除了该应用程序中的所有控制台日志。仍未加载Web部件。

然后我认为加载JS的顺序可能有问题。因此,我已经注释了所有代码和包导入语句。但没有运气。

在“一些文章”中,我发现母版页可能有问题。因此,我已删除了自定义母版,然后又重新设置母版。但是仍然有问题。

然后,我在打开开发人员控制台的情况下加载了页面,发现控制台中存在问题

  

对象不支持属性或方法“警告”

,它是从 sp-classic-page-assembly_en-us.js 抛出的。

有时,我还可以从 sp-classic-page-assembly_en-us.js 看到堆栈溢出错误。

下面是示例ViewModel.ts文件代码。

import * as ko from 'knockout';
import styles from './Search.module.scss';
import { ISearchWebPartProps } from './SearchWebPart';
import pnp, { SearchResults, Web, SearchResult, SortDirection } from 'sp-pnp-js';
import { QueryBuilder } from './Support/QueryBuilder';
import { SearchParameters } from './Entities/SearchParameters';
import { CommonFunctions } from './Support/CommonFunctions';
import { AppConstants } from './Constants/AppConstants';
import { ListNames } from './Constants/ListNames';
import { DocumentCategory } from './Entities/DocumentCategory';
import { ResultTableProperties } from './Entities/ResultTableProperties';
import { PinnedDocuments } from './Entities/PinnedDocuments';
import { SPComponentLoader } from '@microsoft/sp-loader';
import * as $ from "jquery";
import { Topics } from './Entities/Topics';
import { PinnedLists } from "./Entities/PinnedLists";
import { UserPinnedLists } from "./Entities/UserPinnedLists";
import { ConfigProperties } from "./Entities/ConfigProperties";
import { ConfigKeys } from "./Constants/ConfigKeys";
import 'jqueryui';
require('./es6-promise.auto.min.js');
let Swal: any = require('./sweetalert2.min.js');
let moment: any = require('./MyWIMS-I/js/moment.min.js');

require('./SwalStyles.css');



export interface ISearchBindingContext extends ISearchWebPartProps {
    shouter: KnockoutSubscribable<{}>;
}

export default class SearchViewModel {

    public resultTablePageSize: KnockoutObservable<number> = ko.observable(50);
    public mmsName: KnockoutObservable<string> = ko.observable("");
    public topicsTermID: KnockoutObservable<string> = ko.observable("");
    public startPageNumber: KnockoutObservable<number> = ko.observable(1);
    public lastPageNumber: KnockoutObservable<number> = ko.observable(1);
    public currentPageNumber: KnockoutObservable<number> = ko.observable(1);
    public pinnedDocumentsCount: KnockoutObservable<number> = ko.observable(0);
    public isPrevEnabled: KnockoutObservable<boolean> = ko.observable(false);
    public isNextEnabled: KnockoutObservable<boolean> = ko.observable(false);
    public selectedCategory: KnockoutObservable<string> = ko.observable('');
    public resultTableDocProperties: KnockoutObservableArray<ResultTableProperties> = ko.observableArray([]);
    public rootCategoryDetails: KnockoutObservableArray<DocumentCategory> = ko.observableArray([]);
    public topicsTerms: KnockoutObservableArray<Topics> = ko.observableArray([]);
    public pinnedsectionDetails: KnockoutObservableArray<PinnedLists> = ko.observableArray([]);
    public selectpinListDetails: KnockoutObservableArray<UserPinnedLists> = ko.observableArray([]);
    public associatedLists: KnockoutObservableArray<string> = ko.observableArray([]);
    public docToUnPin: KnockoutObservable<string> = ko.observable('');

    public searchParameters: KnockoutObservable<SearchParameters> = ko.observable(new SearchParameters());
    public openedPinnedList: KnockoutObservable<PinnedLists> = ko.observable(new PinnedLists());
    public isLoading: KnockoutObservable<boolean> = ko.observable(true);
    public isPinnedSectionOpen: KnockoutObservable<boolean> = ko.observable(false);
    public webAbsUrl: string = '';
    public webServRelUrl: string = '';
    public docCategoryDetails: DocumentCategory[] = [];
    private oWeb: Web = undefined;

    constructor(bindings: ISearchBindingContext) {

        this.webAbsUrl = bindings.webAbsUrl;
        this.webServRelUrl = bindings.webServRelUrl;
        this.isLoading(true);
        this.resultTablePageSize(parseInt(bindings.pageSize));
        this.mmsName(bindings.mmsName);
        this.topicsTermID(bindings.topicsTermID);
        this.oWeb = new Web(bindings.webAbsUrl);
        SPComponentLoader.loadScript(this.webAbsUrl + '/_layouts/15/clienttemplates.js', { globalExportsName: 'jQuery' }).then((jQuery: any): void => {
        });

        SPComponentLoader.loadCss(this.webAbsUrl + '/SiteAssets/css/bootstrap.min.css');
        SPComponentLoader.loadCss('https://fonts.googleapis.com/css?family=Poppins:300,400,500,600,700');
        SPComponentLoader.loadScript(this.webAbsUrl + '/SiteAssets/js/jquery-2.2.4.min.js', { globalExportsName: 'jQuery' }).then((jQuery: any): void => {
            SPComponentLoader.loadScript(this.webAbsUrl + '/SiteAssets/js/jquery-ui.min.js', { globalExportsName: 'jQuery' }).then((jQuery: any): void => {
                SPComponentLoader.loadScript(this.webAbsUrl + '/SiteAssets/js/bootstrap.min.js', { globalExportsName: 'jQuery' }).then((): void => {
                    SPComponentLoader.loadScript('https://cdnjs.cloudflare.com/ajax/libs/core-js/2.4.1/core.js', { globalExportsName: 'jQuery' }).then((): void => {
                    });
                });
            });
        });


        this.oWeb.currentUser.get().then((_currentUser: any) => {
            this.currentUserID = _currentUser.Id;
            this.GetUserPinnedLists();
            const sessionKey: string = CommonFunctions.GetQueryStringParameter(AppConstants.CONST_Session_Key);
            const _srchParams: SearchParameters = CommonFunctions.GetSearchParameters(sessionKey);
            this.searchParameters(_srchParams);            
            this.InitiateWIMSSearch();          
        });
    }

    private GetUserPinnedLists(): void {
        this.pinnedListsDetails = [];
        this.oWeb.lists.getByTitle(ListNames.LIST_User_Specific_Pinned_Lists).items.filter("UserNameId eq " + this.currentUserID).orderBy("PinnedListOrder", true).get().then(_pinnedLists => {
            if (_pinnedLists && _pinnedLists.length > 0) {
                for (let i = 0; i < _pinnedLists.length; i++) {
                    this.pinnedListsDetails.push({ ListName: _pinnedLists[i].Title, ListID: _pinnedLists[i].ID, Documents: [], IsExpanded: false, IsSeeMoreVisible: true });
                }
            }
            this.pinnedListsDetails.push({ ListName: AppConstants.CONST_DEFAULT_PinnedList, ListID: 1, Documents: [], IsExpanded: false, IsSeeMoreVisible: true });
        }).catch(e => { this.LogException("GetUserPinnedLists", e); });
    }

    private InitiateWIMSSearch(): void {
        this.GetTopicsTerms();
        this.SearchDocuments(1);        
    }
}

任何建议都会有所帮助。谢谢。

0 个答案:

没有答案