错误(TypeError:无法读取null(...)的属性“样式”)在调用placeAt()方法时弹出 [英] Error (TypeError: Cannot read property 'style' of null(…)) pop out whenever placeAt() method is called

查看:221
本文介绍了错误(TypeError:无法读取null(...)的属性“样式”)在调用placeAt()方法时弹出的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

以下代码在我的其他项目中正常工作,但当我将对象放在当前项目中的div时,它会不断弹出此错误。有没有必要注意placeAt()方法?

The following codes works fine in my other project but it keep pop out this error when i placing a object to div in current project. is there any concern must be aware for placeAt() method?

rest.then(function(response){
                var dataset = response.data;
                array.forEach(dataset, function(single, i){
                    if(dataset[i].favorite){
                        favorite++;
                    }

                    if(dataset[i].status == "OO"){
                        outOfService++;
                    }
                });

                try{
                    var dashBoardShortCutCell = new DashBoardShortCutCell();
                    dashBoardShortCutCell.construct("favorite", favorite);
                    dashBoardShortCutCell.placeAt(context.shortCutContainerNode);
                }catch(err){
                    console.log(err);
                }

                dashBoardShortCutCell = new DashBoardShortCutCell();
                dashBoardShortCutCell.construct("Out of Service", outOfService);

                try{

                    dashBoardShortCutCell.placeAt(context.shortCutContainerNode);
                }catch(err){
                    console.log(err);
                }

            }, function(err){
                console.log("Error", err);
            }, function(evt){

            });

然后显示控制台:

DashboardPage.js:85 TypeError:无法读取属性'style'为null(...)

DashboardPage.js:85 TypeError: Cannot read property 'style' of null(…)

DashboardPage.js:95 TypeError:无法读取属性'style'为null )

DashboardPage.js:95 TypeError: Cannot read property 'style' of null(…)

推荐答案

无法读取属性style为null

"Cannot read property 'style' of null"

从错误本身已经提到的根本原因。您的JavaScript正在尝试对未定义/空节点进行一些样式。请确保您正确定义了目标节点

From the error itself already mentioned the root cause. Your JavaScript is trying to do some styling to undefined/null node. Please make sure you defined properly the target node

这篇关于错误(TypeError:无法读取null(...)的属性“样式”)在调用placeAt()方法时弹出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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