第二次调用函数返回 Uncaught TypeError: ##### is not a function(Second call to a function returns Uncaught TypeError: ##### is not a function)答案

我在 JS/jQuery 上相当没用,而且还涉及很多其他代码和动画,不容易分享,但谁能告诉我为什么这一切都很好,直到它到达最后一个 wordpressAnim();

第一次调用wordpressAnim(); 工作正常,但再次调用时出现错误:

未捕获的类型错误:wordpressAnim 不是函数

function magentoComplete(){ console.log("Magento COMPLETE"); magentoContainer.hide(); wordpressAnim(); } function wordpressComplete(){ console.log("Wordpress Complete"); wordpressAnim.hide(); woocommerceAnim(); } function wooComplete(){ console.log("Woocommerce Complete"); wooContainer.hide(); wordpressAnim(); } 

抱歉,之前没有添加。这是wordpressAnim(); 函数:

var wordpress = $('.wordpress_anim'), wordpressAnim; function wordpressAnim(){ var tlWordpressVisible = new TimelineLite tlWordpressSetup = new TimelineLite wordpressAnim = $('.wordpress_anim'), wordpressText1 = $('.wordpress_anim .text1'), wordpressText2 = $('.wordpress_anim .text2'), wordpressPercent1 = $('.wordpress_anim .percent1'), wordpressPercent2 = $('.wordpress_anim .percent2'), wordpressCircle_front_89 = $('.wordpress_anim .circle_front_89'), wordpressCircle_front_50 = $('.wordpress_anim .circle_front_50'), wordpressPercent1Number = $('.wordpress_anim .percent1Number'), wordpressPercent2Number = $('.wordpress_anim .percent2Number'), wordpressCircle_back = $('.wordpress_anim .circle_back'), wordpressLogo = $('.wordpress_anim .wordpress'), wordpressCounter = { var: 0 }, tlWordpress_anim = new TimelineMax; tlWordpressVisible.set("circle,polygon,polyline,line,polygon,path, rect", {visibility:"visible"}); tlWordpressSetup.set(".wordpress_anim .percent2, .wordpress_anim .text2", {visibility:"hidden"}); tlWordpress_anim .to(wordpressCounter, 3.5, { var: 89, onUpdate: function () { $(wordpressPercent1Number).html(Math.ceil(wordpressCounter.var)); }, ease:Power3.easeInOut }) .from(wordpressLogo, 1, { y:-50, opacity:0, ease:Power3.easeInOut}, '-=3.5') .from(wordpressCircle_back, 0.5, { opacity:0, ease:Power3.easeInOut }, '-=3.5') .from(wordpressText1, .5, { y:10, opacity:0, ease:Power3.easeInOut}, '-=2.25') .from(wordpressCircle_front_89, 1.5, { drawSVG:"0 0", ease:Power3.easeInOut}, '-=2') .to(wordpressText1, .5, { y:200, opacity:0, ease:Power3.easeInOut}, 9) // Start second WordPress Anim .to(wordpressPercent1, .5, { opacity:0, ease:Power3.easeInOut}, '-=.25') .to(wordpressCircle_front_89, .5, { opacity:0, ease:Power3.easeInOut}, '-=.5') .set(wordpressPercent2, {visibility:"visible"}) .set(wordpressText2, {visibility:"visible"}) .set(wordpressCounter, { var: 0 }) .to(wordpressCounter, 1.5, { var: 50, onUpdate: function () { $(wordpressPercent2Number).html(Math.ceil(wordpressCounter.var)); }, ease:Power3.easeInOut }) .from(wordpressText2, .5, { y:10, opacity:0, ease:Power3.easeInOut}, '-=1.5') .from(wordpressCircle_front_50, 1.5, { drawSVG:"0 0", ease:Power3.easeInOut}, '-=1.5') .to(wordpressAnim, .5, { y:200, opacity:0, ease:Power3.easeInOut}, 18) .to(wordpressAnim, .1, { opacity:0, ease:Power3.easeInOut, onComplete: wordpressComplete}); } 

【问题讨论】:

此文由“快兔兔AI采集器”自动生成,目的为演示采集器效果,若侵权请及时联系删除。

原文链接:https://www.likecs.com/ask-3710440.html

更多内容