首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >未捕获的方向:无法读取未定义的属性“TypeError”

未捕获的方向:无法读取未定义的属性“TypeError”
EN

Stack Overflow用户
提问于 2014-06-23 06:40:08
回答 1查看 2.6K关注 0票数 0

我正在创建记忆游戏。我想翻转卡片(Div),让它更逼真。对于翻转,我使用THIS插件。问题是翻牌不起作用。我从控制台得到这个错误:

代码语言:javascript
复制
Uncaught TypeError: Cannot read property 'direction' of undefined 

你可以在这里看到我的代码:JSFIDDLE

编辑1:

完整的错误日志:

代码语言:javascript
复制
Uncaught TypeError: Cannot read property 'direction' of undefined VM24:1
(anonymous function) VM24:1
m.extend.each jquery.min.js:2
m.fn.m.each jquery.min.js:2
$.fn.flip VM24:1
OpenCard mem.js:94
m.event.dispatch jquery.min.js:3
r.handle

此函数使用包含的Jquery Flip插件的flip()函数:

代码语言:javascript
复制
function OpenCard() {
    var id = $(this).attr("id");

    if ($("#" + id + " img").is(":hidden")) {
        $(Source + " div").unbind("click", OpenCard);

        $("#" + id + " img").flip();

        if (ImgOpened == "") {
            BoxOpened = id;
            ImgOpened = $("#" + id + " img").attr("src");
            setTimeout(function() {
                $(Source + " div").bind("click", OpenCard)
            }, 300);
        } else {
            CurrentOpened = $("#" + id + " img").attr("src");
            if (ImgOpened != CurrentOpened) {
                setTimeout(function() {
                    $("#" + id + " img").flip();
                    $("#" + BoxOpened + " img").flip();
                    BoxOpened = "";
                    ImgOpened = "";
                }, 400);
                Counter-=10;
                wrong.play();
            } else {
                $("#" + id + " img").parent().css("disabled", "disabled");
                $("#" + BoxOpened + " img").parent().css("disabled", "disabled");
                ImgFound++;
                BoxOpened = "";
                ImgOpened = "";
                Counter+=100;
                correct.play();
            }
            setTimeout(function() {
                $(Source + " div").bind("click", OpenCard)
            }, 400);
        }
        $("#counter").html("" + Counter);

        if (ImgFound == ImgSource.length) {
        clearInterval(timer);
        alert ("Your score is "+Counter);
        }
    }
}

谁能告诉我为什么会出现这个错误,以及如何修复它

EN

回答 1

Stack Overflow用户

发布于 2014-06-23 06:54:52

您缺少设置对象:

代码语言:javascript
复制
$("#" + id + " img").flip({direction: 'lr'});

您可以在plugin page中获得一些示例。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/24356442

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档