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

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

问题描述



  • li>这是baby.js代码到我的代码中

  • 但我收到一个错误。 TypeError:无法读取未定义的属性'tigerStart'
  • 您可以告诉我如何解决它。

  • 在下面提供我的代码





  • TypeError:Can not在init.open(pen-pencil.ts:1270)
    在init.trigger(kendo.all.min.js:25)
    处读取未定义
    的属性'tigerStart'。 open(kendo.all.min.js:45)Penguin.openPopup(pen-pencil.ts:1286)
    penguin.pencilClicked(headset.ts:689)
    _View_penguin4
    在eval(core.umd.js:9698)处
    (在eval(platform-b​​rowser.umd.js:1877)处
    在eval处

    at ZoneDelegate.invoke(zone.js:203)

    将tigerStart方法转换为整个js代码 b


    $ b

    @ViewChild(sports)public sky:sports ;

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

    包括fish组件到我的html中

    < div class =clearFloat>< / div>
    < ul class =kendu-custom-contextmenuid =context-menuFinancialSearch>
    < li class =kPopUpBtnTriple>查看详情< / li>
    < li class = kPopUpBtnTriple>管理文档< / li>
    < / ul>

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

    <鱼>< /鱼>
    <企鹅(documentC 'mount)= getDocumentEvent($事件)>< /企鹅>
    < sports>< / sports>

    < div class =searchNameRequiredPopup>
    < div class =pipepobUpBox pipeWindow kPopupConfirmationBox>
    < div class =row pipePopUpGridCollection pipePopUpContent lineHeightInputs>
    < div class =pipeContent>请输入搜寻名称。< / div>
    < / div>
    < div class =clearFloat>< / div>
    < div class =row pipePopUpFooter textAligncenterImp>
    <! - < button class =commonBtntype =buttonid =deleteDocumentYes>是< / button> - >
    < button class =clearBtntype =buttonid =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);
    }

    }




    • 当我打印这张照片时,我没有看到天空,所以我阅读了介质表格,并用胖箭头尝试并绑定,但仍然无法执行它。

    • 在视图中的孩子I

    • 您可以告诉我如何解决这个问题。

    • 以便将来有帮助



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

    @ViewChild(sports)public sky:sports;
    ** - 用胖箭头尝试**
    open:()=> {

    ** - 尝试绑定**
    this.sky.tigerStart()。bind(this);


    解决方案














    您可以这样调试:


    • 首先,您应该确保具有属性键 tigerStart 实际上会返回一个对象而不是未定义的。


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

      {
    tiger:{
    tigerStart:true
    }
    }

    if(typeof tiger!='undefined'){
    / *您的代码来自这里* /
    }


    • I am new to typescript and angular js.
    • I tried to include another component code into my code.
    • which is baby.js code into my code
    • but I am getting an error. TypeError: Cannot read property 'tigerStart' of undefined
    • can you guys tell me how to fix it.
    • providing my code below

    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);
      }
    
    }
    

    • when I print this I didn't see sky, so I read the medium form and tried with fat arrow and bind but still I am not able to achived it.
    • in the view child I am using sports
    • can you tell me how to fix it.
    • so that for future it will be helpful

    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 :

    • First, you should make sure that an object having property key tigerStart actually returns an object and not "undefined".

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

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

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

    查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆