typeError: 无法读取属性 'tigerStart'未定义的 [英] typeError: Cannot read property 'tigerStart' of undefined

查看:51
本文介绍了typeError: 无法读取属性 'tigerStart'未定义的的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

  • 我是 typescript 和 angular js 的新手.
  • 我试图在我的代码中包含另一个组件代码.
  • 这是我的代码中的 baby.js 代码
  • 但是我遇到了错误.类型错误:无法读取未定义的属性tigerStart"
  • 你们能告诉我如何修复它吗.
  • 在下面提供我的代码

TypeError: 无法读取未定义的属性 'tigerStart'在 init.open (pen-pencil.ts:1270)在 init.trigger (kendo.all.min.js:25)在 init.open (kendo.all.min.js:45)在 Penguin.openPopup (pen-pencil.ts:1286)在 penguin.pencilClicked (headset.ts:689)在 _View_penguin4._handle_click_45_0 (penguin.ngfactory.js:4087)在 eval (core.umd.js:9698)在 eval (platform-b​​rowser.umd.js:1877)在 eval (platform-b​​rowser.umd.js:1990)在 ZoneDelegate.invoke (zone.js:203)

在整个js代码中包含tigerStart方法

@ViewChild(sports) 公共天空:体育;

that.window = $("#PenguinPopup");that.window.kendoWindow({宽度:60%",标题:假的,可见:假,可调整大小:假,行动:[],可拖动:假,模态:真,打开:函数(){$("html, body").css("溢出", "隐藏");that.isVisible = true;$('.kPopUpTitle').html(values.title);this.sky.tigerStart();

在我的 html 中包含鱼组件

<div class="clearFloat"></div><ul class="kendu-custom-contextmenu" id="context-menuFinancialSearch"><li class="kPopUpBtnTriple">查看详情</li><li class="kPopUpBtnTriple">管理文档</li><financeLeftSlider (savedSearchData)='getSaveEvent($event)'></financeLeftSlider><鱼></鱼><企鹅 (documentCount)='getDocumentEvent($event)'></Penguin><体育></体育><div class="searchNameRequiredPopup"><div class="pipepobUpBox pipeWindow kPopupConfirmationBox"><div class="row pipePopUpGridCollection pipePopUpContent lineHeightInputs"><div class="pipeContent">请输入搜索名称.</div>

<div class="clearFloat"></div><div class="row pipePopUpFooter textAligncenterImp"><!-- <button class="commonBtn" type="button" id ="deleteDocumentYes">Yes</button>--><button class="clearBtn" type="button" id="searchNameRequiredBtn">好的</button>

<div class="clearFloat"></div>

baby.html

<div id="baby"></div><div id="baby1"></div>

baby.js

@Component({模块 ID:module.id,选择器:'体育',templateUrl: 'sports.html'})出口类星{老虎开始():无效{kendo.ui.sky($("#baby"), true);}老虎结束():无效{kendo.ui.sky($("#baby"), false);}虎开始1():无效{kendo.ui.sky($("#baby1"), true);}TigerEnd1():无效{kendo.ui.sky($("#baby1"), false);}}

https://medium.com/@thejasonfile/es5-functions-vs-es6-fat-arrow-functions-864033baa1a

@ViewChild(sports) 公共天空:体育;**- 尝试使用粗箭头**打开:() =>{**- 尝试绑定**this.sky.tigerStart().bind(this);

解决方案

看起来像一个具有属性键 tigerStart 的对象是未定义的.

你可以这样调试:

示例:假设 tiger 是一个具有键为 tigerStart 的属性的对象.

<代码>{老虎": {老虎开始":真}}如果(老虎类型!= '未定义'){/* 你的代码在这里 */}

TypeError: Cannot read property 'tigerStart' of undefined
    at init.open (pen-pencil.ts:1270)
    at init.trigger (kendo.all.min.js:25)
    at init.open (kendo.all.min.js:45)
    at Penguin.openPopup (pen-pencil.ts:1286)
    at penguin.pencilClicked (headset.ts:689)
    at _View_penguin4._handle_click_45_0 (penguin.ngfactory.js:4087)
    at eval (core.umd.js:9698)
    at eval (platform-browser.umd.js:1877)
    at eval (platform-browser.umd.js:1990)
    at ZoneDelegate.invoke (zone.js:203)

including tigerStart method into whole js code

@ViewChild(sports) public sky: sports;

that.window = $("#PenguinPopup");
that.window.kendoWindow({
  width: "60%",
  title: false,
  visible: false,
  resizable: false,
  actions: [],
  draggable: false,
  modal: true,
  open: function() {
    $("html, body").css("overflow", "hidden");
    that.isVisible = true;
    $('.kPopUpTitle').html(values.title);
    this.sky.tigerStart();

including fish component into my html

<div class="clearFloat"></div>
<ul class="kendu-custom-contextmenu" id="context-menuFinancialSearch">
  <li class="kPopUpBtnTriple">View Details</li>
  <li class="kPopUpBtnTriple">Manage Documents</li>
</ul>

<financeLeftSlider (savedSearchData)='getSaveEvent($event)'></financeLeftSlider>

<Fish></Fish>
<Penguin (documentCount)='getDocumentEvent($event)'></Penguin>
<sports></sports>

<div class="searchNameRequiredPopup">
  <div class="pipepobUpBox pipeWindow kPopupConfirmationBox">
    <div class="row pipePopUpGridCollection pipePopUpContent lineHeightInputs">
      <div class="pipeContent">Please enter the search name.</div>
    </div>
    <div class="clearFloat"></div>
    <div class="row pipePopUpFooter textAligncenterImp">
      <!-- <button class="commonBtn" type="button" id ="deleteDocumentYes">Yes</button> -->
      <button class="clearBtn" type="button" id="searchNameRequiredBtn">Ok</button>
    </div>
    <div class="clearFloat"></div>
  </div>
</div>

baby.html

<div id="baby"></div>
<div id="baby1"></div>

baby.js

@Component({
  moduleId: module.id,
  selector: 'sports',
  templateUrl: 'sports.html'
})

export class Star {

  tigerStart(): void {
    kendo.ui.sky($("#baby"), true);
  }
  tigerEnd(): void {
    kendo.ui.sky($("#baby"), false);

  }

  tigerStart1(): void {
    kendo.ui.sky($("#baby1"), true);
  }
  tigerEnd1(): void {
    kendo.ui.sky($("#baby1"), false);
  }

}

https://medium.com/@thejasonfile/es5-functions-vs-es6-fat-arrow-functions-864033baa1a

@ViewChild(sports) public sky: sports;
**- tried with fat arrow**
open: () => {

**- tried with bind**
        this.sky.tigerStart().bind(this);

解决方案

Looking like an object having property key tigerStart is undefined.

You can debug like this :

Example : Suppose tiger is an object having property with key tigerStart.

{
  "tiger": {
    "tigerStart": true
  }
}

if (typeof tiger != 'undefined') {
  /* Your code comes here */
}

这篇关于typeError: 无法读取属性 &amp;#39;tigerStart&amp;#39;未定义的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
前端开发最新文章
热门教程
热门工具
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆