javascript – 添加新参数后发生错误

前端之家收集整理的这篇文章主要介绍了javascript – 添加新参数后发生错误前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

我有一个测试用例工作正常,但在我的方法swiming中添加一个额外的参数tiger后,它正在破坏.

我甚至将新参数tiger传递给我的测试用例,但它仍在破坏.

更新
我在这一行得到网格未定义…现在任何想法如何继续让grid = $(‘#henTigerGrid’).data(‘kendoGrid’);

let tiger = {
    "nail": "hens/v1/sky/88888888888888","columns": [],"title": "DOCUMENTS","excelFileName": "ViewAiringsExport","mainId": 88888888888888
};

代码如下:

错误

[0] 14 09 2017 19:56:26.250:DEBUG [web-server]: serving (cached): C:/Desktop/08-31-afternoon/webcomponent/src/main/webapp/app/components/finan    LOG: 'model.skyName--->text.txt'
    LOG: 'tiger.naile---->hens/v1/sky/88888888888888'
    Chrome 60.0.3112 (Windows 10 0.0.0) Jasmine Unit Tests: Help-Dashboard-Manage-Tiger Add start Finger Failed
[0]     TypeError: Cannot read property '_data' of undefined
    Chrome 60.0.3112 (Windows 10 0.0.0): Executed 14 of 29 (1 Failed) (0 secs / 2.796 secs)

swiming(evt,dropValue,tiger) {
    let todayDate = this.todayDate();
    let grid = $('#henTigerGrid').data('kendoGrid');
    let _dataSource = grid.dataSource;
    let pageSize = _dataSource.pageSize();

    //console.log("_dataSource._data---->" + _dataSource._data.length);

    let gridLength = _dataSource._data.length;
    let filename;

    console.log("loggedUserName---->" + $(".loggedUserName").text());

    let attributes=this.sportsService.getSeesionStorageValue();

    if(attributes) {
        this.parrotrId = attributes.parrotr_attributes.SSO[0];
        this.loggedUserName = attributes.parrotr_attributes.DisplayName[0];
    }

    if(this.fileSelect == null || this.fileSelect == "") {
        _dataSource.insert(gridLength,{
            "skyId": "104","skyName": filename,});
    } else {
        let temparry = [];
        let attributes = this.sportsService.getSeesionStorageValue();
        let lastIndex = this.fileSelect.lastIndexOf(".");

        if(lastIndex >= 0) {
            filename = this.fileSelect; //.substring(lastIndex,0);
        }

        var fileSize = 0;
        fileSize = fileSize / 1048576; //size in mb

        let k = _dataSource._data.length;

        _dataSource.insert(k,{
            "skyId": "105",});

        //temparry.push(data)
        let skyData = {};
        //skyData["gridData"] = data;

        this.dragDrop = "";
        this.dragDrop = this.clearBtn;

        $("#attachFingerBrowseBtn").val('');
        this.fileSelect = "";

        let data_source = _dataSource.data();
        for(let d = 0; d < data_source.length; d++) {
            if(data_source[d].isElfDoc == true
            && data_source[d].sublimeDocID == "") {
                //this.gridkendo.enableSaveFinger(false);
            }
        }
    }

    $('.addSkipingerForm').hide();
    let permissionDto = "";
    let functionalList = "";

    if(true) {
        let currentData = _dataSource._data;
        // console.log("filename---->" + filename);
        console.log("tiger.naile---->" + tiger.nail);
        //this.selectedFingerId=tiger.nail;

        this.selectedFingerId=tiger.nail;

        // var str = "hens/v1/sky/35369";
        var strx = this.selectedFingerId;
        var res = strx.substring(23);

        let attributes = this.sportsService.getSeesionStorageValue();

        if(attributes) {
            this.parrotrId = attributes.parrotr_attributes.SSO[0];
            this.loggedUserName = attributes.parrotr_attributes.DisplayName[0];
        }

        let compassUser = this.parrotrId;
        // console.log("this.parrotrId---->" + this.parrotrId);
        // console.log("this.parrotrId---->" + this.loggedUserName);
        //"skyId": this._dataSource._data.length+1,let records = [
            {
                "id": res,"skyDtos" : [{
                    "skyId": this._dataSource._data.length + 1,"operationType": "create",}]
            }
        ];

        for(let i = 0; i < currentData.length; i++) {
            if(currentData[i].skyId == "") {

            }
        }

        for(let i = 0; i < _dataSource._destroyed.length; i++) {

        }

        this.sportsService
            .getResponse("hens/v1/sky/","post",records[0])
            .subscribe(data => {

                console.log("data---->" + data);
                if (data.code == 'S001') {

                } else {

                }
            },err => {

            }
        );
    }

    $('.k-pager-numbers li').last().find('a').click();
}

测试用例

describe('Jasmine Unit Tests: Help-Dashboard-Manage-Tiger',() => {
    let detailsportsService:SPORTSService;
    let sportsService: SPORTSService;
    let decodeService: DecodeService;
    let fish: HelpDashboardContract;
    let henViewDetailsComponent: startViewDetails;
    let scroll: ComponentFixture
最佳答案
嘿,我发现它,如果我删除此行错误得到修复

                "skyId": this._dataSource._data.length + 1,

猜你在找的JavaScript相关文章