账号密码登录
微信安全登录
微信扫描二维码登录

登录后绑定QQ、微信即可实现信息互通

手机验证码登录
找回密码返回
邮箱找回 手机找回
注册账号返回
其他登录方式
分享
  • 收藏
    X
    element tree setChecked 不生效?
    28
    0

    [

    {
        "FolderId":"folder_001",
        "FolderName":"全部",
        "FolderLevel":0,
        "Disable":true,
        "children":[
            {
                "FolderId":"folder_005",
                "FolderName":"地锦路2号院",
                "FolderLevel":1,
                "Disable":true,
                "children":[
                    {
                        "FolderId":"folder_1530757700031164600",
                        "FolderName":"111",
                        "FolderLevel":2,
                        "Disable":true,
                        "children":[
                            {
                                "DeviceId":"device_00001112",
                                "DeviceName":"name2",
                                "Protocol":"28281",
                                "GbId":"5.20000000000122e+20",
                                "Server":{
                                    "ServerId":"server_0000001",
                                    "ServerName":"",
                                    "Protocol":"",
                                    "GbId":"",
                                    "Launch":false,
                                    "ServerIp":"",
                                    "ServerPort":0,
                                    "ServerPassword":"",
                                    "Devices":null
                                },
                                "StreamServerId":"",
                                "RtmpUrl":"",
                                "HttpFlvUrl":"",
                                "HlsUrl":"",
                                "ClientId":"",
                                "Launch":true,
                                "HasPtz":true,
                                "DeviceIp":"",
                                "DevicePort":0,
                                "DevicePassword":"",
                                "label":"name2",
                                "id":"device_00001112",
                                "disabled":false
                            }
                        ],
                        "label":"111",
                        "id":"folder_1530757700031164600",
                        "disabled":true
                    },
                    {
                        "DeviceId":"device_00001111",
                        "DeviceName":"name1",
                        "Protocol":"28281",
                        "GbId":"520000000000122345550",
                        "Server":{
                            "ServerId":"server_0000001",
                            "ServerName":"",
                            "Protocol":"",
                            "GbId":"",
                            "Launch":false,
                            "ServerIp":"",
                            "ServerPort":0,
                            "ServerPassword":"",
                            "Devices":null
                        },
                        "StreamServerId":"",
                        "RtmpUrl":"",
                        "HttpFlvUrl":"",
                        "HlsUrl":"",
                        "ClientId":"",
                        "Launch":true,
                        "HasPtz":true,
                        "DeviceIp":"",
                        "DevicePort":0,
                        "DevicePassword":"",
                        "label":"name1",
                        "id":"device_00001111",
                        "disabled":false
                    }
                ],
                "label":"地锦路2号院",
                "id":"folder_005",
                "disabled":true
            },
            {
                "FolderId":"folder_004",
                "FolderName":"地锦路1号院",
                "FolderLevel":1,
                "Disable":true,
                "children":[
                    {
                        "DeviceId":"device_00001111",
                        "DeviceName":"name1",
                        "Protocol":"28281",
                        "GbId":"520000000000122345550",
                        "Server":{
                            "ServerId":"server_0000001",
                            "ServerName":"",
                            "Protocol":"",
                            "GbId":"",
                            "Launch":false,
                            "ServerIp":"",
                            "ServerPort":0,
                            "ServerPassword":"",
                            "Devices":null
                        },
                        "StreamServerId":"",
                        "RtmpUrl":"",
                        "HttpFlvUrl":"",
                        "HlsUrl":"",
                        "ClientId":"",
                        "Launch":true,
                        "HasPtz":true,
                        "DeviceIp":"",
                        "DevicePort":0,
                        "DevicePassword":"",
                        "label":"name1",
                        "id":"device_00001111",
                        "disabled":false
                    },
                    {
                        "DeviceId":"device_00001112",
                        "DeviceName":"name2",
                        "Protocol":"28281",
                        "GbId":"5.20000000000122e+20",
                        "Server":{
                            "ServerId":"server_0000001",
                            "ServerName":"",
                            "Protocol":"",
                            "GbId":"",
                            "Launch":false,
                            "ServerIp":"",
                            "ServerPort":0,
                            "ServerPassword":"",
                            "Devices":null
                        },
                        "StreamServerId":"",
                        "RtmpUrl":"",
                        "HttpFlvUrl":"",
                        "HlsUrl":"",
                        "ClientId":"",
                        "Launch":true,
                        "HasPtz":true,
                        "DeviceIp":"",
                        "DevicePort":0,
                        "DevicePassword":"",
                        "label":"name2",
                        "id":"device_00001112",
                        "disabled":false
                    }
                ],
                "label":"地锦路1号院",
                "id":"folder_004",
                "disabled":true
            },
            {
                "FolderId":"folder_003",
                "FolderName":"水枝市",
                "FolderLevel":1,
                "Disable":true,
                "children":[
                    {
                        "DeviceId":"device_00001112",
                        "DeviceName":"name2",
                        "Protocol":"28281",
                        "GbId":"5.20000000000122e+20",
                        "Server":{
                            "ServerId":"server_0000001",
                            "ServerName":"",
                            "Protocol":"",
                            "GbId":"",
                            "Launch":false,
                            "ServerIp":"",
                            "ServerPort":0,
                            "ServerPassword":"",
                            "Devices":null
                        },
                        "StreamServerId":"",
                        "RtmpUrl":"",
                        "HttpFlvUrl":"",
                        "HlsUrl":"",
                        "ClientId":"",
                        "Launch":true,
                        "HasPtz":true,
                        "DeviceIp":"",
                        "DevicePort":0,
                        "DevicePassword":"",
                        "label":"name2",
                        "id":"device_00001112",
                        "disabled":false
                    },
                    {
                        "DeviceId":"device_00001111",
                        "DeviceName":"name1",
                        "Protocol":"28281",
                        "GbId":"520000000000122345550",
                        "Server":{
                            "ServerId":"server_0000001",
                            "ServerName":"",
                            "Protocol":"",
                            "GbId":"",
                            "Launch":false,
                            "ServerIp":"",
                            "ServerPort":0,
                            "ServerPassword":"",
                            "Devices":null
                        },
                        "StreamServerId":"",
                        "RtmpUrl":"",
                        "HttpFlvUrl":"",
                        "HlsUrl":"",
                        "ClientId":"",
                        "Launch":true,
                        "HasPtz":true,
                        "DeviceIp":"",
                        "DevicePort":0,
                        "DevicePassword":"",
                        "label":"name1",
                        "id":"device_00001111",
                        "disabled":false
                    }
                ],
                "label":"水枝市",
                "id":"folder_003",
                "disabled":true
            },
            {
                "FolderId":"folder_002",
                "FolderName":"钟山市",
                "FolderLevel":1,
                "Disable":true,
                "children":[
                    {
                        "FolderId":"folder_008",
                        "FolderName":"钟山公安局",
                        "FolderLevel":2,
                        "Disable":true,
                        "children":[
                            {
                                "DeviceId":"device_00001112",
                                "DeviceName":"name2",
                                "Protocol":"28281",
                                "GbId":"5.20000000000122e+20",
                                "Server":{
                                    "ServerId":"server_0000001",
                                    "ServerName":"",
                                    "Protocol":"",
                                    "GbId":"",
                                    "Launch":false,
                                    "ServerIp":"",
                                    "ServerPort":0,
                                    "ServerPassword":"",
                                    "Devices":null
                                },
                                "StreamServerId":"",
                                "RtmpUrl":"",
                                "HttpFlvUrl":"",
                                "HlsUrl":"",
                                "ClientId":"",
                                "Launch":true,
                                "HasPtz":true,
                                "DeviceIp":"",
                                "DevicePort":0,
                                "DevicePassword":"",
                                "label":"name2",
                                "id":"device_00001112",
                                "disabled":false
                            },
                            {
                                "DeviceId":"device_00001111",
                                "DeviceName":"name1",
                                "Protocol":"28281",
                                "GbId":"520000000000122345550",
                                "Server":{
                                    "ServerId":"server_0000001",
                                    "ServerName":"",
                                    "Protocol":"",
                                    "GbId":"",
                                    "Launch":false,
                                    "ServerIp":"",
                                    "ServerPort":0,
                                    "ServerPassword":"",
                                    "Devices":null
                                },
                                "StreamServerId":"",
                                "RtmpUrl":"",
                                "HttpFlvUrl":"",
                                "HlsUrl":"",
                                "ClientId":"",
                                "Launch":true,
                                "HasPtz":true,
                                "DeviceIp":"",
                                "DevicePort":0,
                                "DevicePassword":"",
                                "label":"name1",
                                "id":"device_00001111",
                                "disabled":false
                            }
                        ],
                        "label":"钟山公安局",
                        "id":"folder_008",
                        "disabled":true
                    },
                    {
                        "FolderId":"folder_007",
                        "FolderName":"钟山交警大队",
                        "FolderLevel":2,
                        "Disable":true,
                        "children":[
                            {
                                "DeviceId":"device_00001112",
                                "DeviceName":"name2",
                                "Protocol":"28281",
                                "GbId":"5.20000000000122e+20",
                                "Server":{
                                    "ServerId":"server_0000001",
                                    "ServerName":"",
                                    "Protocol":"",
                                    "GbId":"",
                                    "Launch":false,
                                    "ServerIp":"",
                                    "ServerPort":0,
                                    "ServerPassword":"",
                                    "Devices":null
                                },
                                "StreamServerId":"",
                                "RtmpUrl":"",
                                "HttpFlvUrl":"",
                                "HlsUrl":"",
                                "ClientId":"",
                                "Launch":true,
                                "HasPtz":true,
                                "DeviceIp":"",
                                "DevicePort":0,
                                "DevicePassword":"",
                                "label":"name2",
                                "id":"device_00001112",
                                "disabled":false
                            },
                            {
                                "DeviceId":"device_00001111",
                                "DeviceName":"name1",
                                "Protocol":"28281",
                                "GbId":"520000000000122345550",
                                "Server":{
                                    "ServerId":"server_0000001",
                                    "ServerName":"",
                                    "Protocol":"",
                                    "GbId":"",
                                    "Launch":false,
                                    "ServerIp":"",
                                    "ServerPort":0,
                                    "ServerPassword":"",
                                    "Devices":null
                                },
                                "StreamServerId":"",
                                "RtmpUrl":"",
                                "HttpFlvUrl":"",
                                "HlsUrl":"",
                                "ClientId":"",
                                "Launch":true,
                                "HasPtz":true,
                                "DeviceIp":"",
                                "DevicePort":0,
                                "DevicePassword":"",
                                "label":"name1",
                                "id":"device_00001111",
                                "disabled":false
                            }
                        ],
                        "label":"钟山交警大队",
                        "id":"folder_007",
                        "disabled":true
                    },
                    {
                        "FolderId":"folder_006",
                        "FolderName":"钟山派出所",
                        "FolderLevel":2,
                        "Disable":true,
                        "children":[
                            {
                                "DeviceId":"device_00001112",
                                "DeviceName":"name2",
                                "Protocol":"28281",
                                "GbId":"5.20000000000122e+20",
                                "Server":{
                                    "ServerId":"server_0000001",
                                    "ServerName":"",
                                    "Protocol":"",
                                    "GbId":"",
                                    "Launch":false,
                                    "ServerIp":"",
                                    "ServerPort":0,
                                    "ServerPassword":"",
                                    "Devices":null
                                },
                                "StreamServerId":"",
                                "RtmpUrl":"",
                                "HttpFlvUrl":"",
                                "HlsUrl":"",
                                "ClientId":"",
                                "Launch":true,
                                "HasPtz":true,
                                "DeviceIp":"",
                                "DevicePort":0,
                                "DevicePassword":"",
                                "label":"name2",
                                "id":"device_00001112",
                                "disabled":false
                            },
                            {
                                "DeviceId":"device_00001111",
                                "DeviceName":"name1",
                                "Protocol":"28281",
                                "GbId":"520000000000122345550",
                                "Server":{
                                    "ServerId":"server_0000001",
                                    "ServerName":"",
                                    "Protocol":"",
                                    "GbId":"",
                                    "Launch":false,
                                    "ServerIp":"",
                                    "ServerPort":0,
                                    "ServerPassword":"",
                                    "Devices":null
                                },
                                "StreamServerId":"",
                                "RtmpUrl":"",
                                "HttpFlvUrl":"",
                                "HlsUrl":"",
                                "ClientId":"",
                                "Launch":true,
                                "HasPtz":true,
                                "DeviceIp":"",
                                "DevicePort":0,
                                "DevicePassword":"",
                                "label":"name1",
                                "id":"device_00001111",
                                "disabled":false
                            }
                        ],
                        "label":"钟山派出所",
                        "id":"folder_006",
                        "disabled":true
                    }
                ],
                "label":"钟山市",
                "id":"folder_002",
                "disabled":true
            }
        ],
        "label":"全部",
        "disabled":true,
        "id":"folder_001"
    }

    ]

    <el-tree
            :data="deviceTree"
            show-checkbox
            default-expand-all
            node-key="id"
            ref="tree"
            :highlight-current="true"
           
            check-strictly
            @check="handleNodeChecked"
            >
            </el-tree>
            

    我的数据是这样的,this.$refs.tree.setChecked(data,false); this.$refs.tree.getNode(data).checked
    都是生效, 怎么回事,用例子给的数据 就生效,是数据有什么问题吗?

    0
    打赏
    收藏
    点击回答
        全部回答
    • 0
    • つ゛爱心创可贴 普通会员 1楼

      elementTree.setChecked方法用于设置元素的选中状态。如果在使用时出现setChecked方法不生效的情况,可能的原因有以下几种:

      1. 元素不存在:在JavaScript中,元素对象的checked属性是undefined。因此,即使在元素存在的情况下,setChecked方法也无法生效。

      2. elementTree对象不存在:在JavaScript中,elementTree对象的实例是一个对象,如果这个对象不存在,那么setChecked方法也无法生效。

      3. 状态不存在:在JavaScript中,元素的状态可以通过elementTree.setAttribute方法进行设置。如果elementTree.setAttribute方法也返回undefined,那么setChecked方法也无法生效。

      4. 问题在于你可能在其他地方调用了elementTree.setChecked方法,但是你的代码没有正确地调用这个方法。

      因此,如果setChecked方法不生效,你需要检查一下你的代码,确保你正确地调用了elementTree.setChecked方法。

    更多回答
    扫一扫访问手机版
    • 回到顶部
    • 回到顶部