第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問(wèn)題,去搜搜看,總會(huì)有你想問(wèn)的

訪問(wèn)anime.js回調(diào)函數(shù)中的Angular組件屬性/函數(shù)

訪問(wèn)anime.js回調(diào)函數(shù)中的Angular組件屬性/函數(shù)

我是 Js 新手,我正在嘗試創(chuàng)建一個(gè)簡(jiǎn)單的應(yīng)用程序,我需要在動(dòng)畫(huà)完成后調(diào)用 Angular 組件函數(shù)。對(duì)于動(dòng)畫(huà),我使用 Anime.js 并使用 Angular 框架來(lái)創(chuàng)建這個(gè)應(yīng)用程序。我已經(jīng)在 ngAfterViewInit 函數(shù)中添加了動(dòng)畫(huà)代碼,并且我想在anime.js 的完整showOptions()回調(diào)中調(diào)用 Angular 組件的函數(shù)。但在完整的回調(diào)中,我無(wú)法訪問(wèn)此組件函數(shù)。我嘗試定義組件對(duì)象comp,然后嘗試在回調(diào)函數(shù)中使用該對(duì)象來(lái)調(diào)用showOptions函數(shù),但它給出了錯(cuò)誤無(wú)法讀取未定義的屬性“showOptions”直接調(diào)用showOptions函數(shù)也不起作用。我的代碼:ngAfterViewInit(): void {    var textWrapper = document.querySelector('.an-2');    textWrapper.innerHTML = textWrapper.textContent.replace(/\S/g, "<span class='letter'>$&</span>");    anime.timeline({loop: false})      .add({        targets: '.an-2 .letter',        opacity: [0,1],        easing: "easeInOutQuad",        duration: 2250,        comp: this,        delay: (el, i) => 150 * (i+1),        complete: function (anim) {          console.log('Completed' + anim);          this.comp.showOptions();        }      });  }showOptions(){   console.log('Show options called.');}
查看完整描述

1 回答

?
MYYA

TA貢獻(xiàn)1868條經(jīng)驗(yàn) 獲得超4個(gè)贊

將正?;卣{(diào)更改為箭頭函數(shù),如下所示:-


ngAfterViewInit(): void {

    var textWrapper = document.querySelector('.an-2');

    textWrapper.innerHTML = textWrapper.textContent.replace(/\S/g, "<span class='letter'>$&</span>");

    anime.timeline({loop: false})

      .add({

        targets: '.an-2 .letter',

        opacity: [0,1],

        easing: "easeInOutQuad",

        duration: 2250,

        comp: this,

        delay: (el, i) => 150 * (i+1),

        complete:(anim) => {

          console.log('Completed' + anim);

          this.comp.showOptions();

        }

      });

  }


showOptions(){

   console.log('Show options called.');

}


查看完整回答
反對(duì) 回復(fù) 2023-10-14
  • 1 回答
  • 0 關(guān)注
  • 99 瀏覽
慕課專(zhuān)欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢(xún)優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)