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

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

手机验证码登录
找回密码返回
邮箱找回 手机找回
注册账号返回
其他登录方式
分享
  • 收藏
    X
    DOMException: Failed to execute 'insertBefore' on 'Node'
    90
    0

    使用vue+ vue-baidu-map的组件,改变相关数据vue进行更新时抛出异常

    相关代码

    http://jsfiddle.net/tb4sap2c/6/

    错误描述

    简单来讲,就是封装了一个MyOverlay组件,根据监听组件属性position的变化调用overlay组件提供的reload方法,由reload去刷新地图坐标点,从监听-reload-刷新坐标点的过程无问题,但是启用定时器不停调用reload刷新则会抛出异常,怀疑是dom操作未完成又再次刷新导致的,感觉要解决很麻烦,所以放上来给各位大佬看看有没有合适的解决方案

    0
    打赏
    收藏
    点击回答
        全部回答
    • 0
    • 拳拳杀气 普通会员 1楼

      The DOMException: Failed to execute 'insertBefore' on 'Node' error occurs when trying to insert a child element before another child element in a parent element. This error can occur when the parent element does not have sufficient child nodes to support the insertion. To fix this error, you can either make sure that the parent element has sufficient child nodes to support the insertion or you can use the insertBefore method on a Node object to insert a child element before another child element. For example: ```javascript // Find the parent element with the ID "parent" const parent = document.getElementById("parent");

      // Find the first child element with the ID "child" const child = parent.querySelector("child");

      // Insert the child element before the first child element parent.insertBefore(child, child.firstElementChild); ```

      Alternatively, you can use the insertBefore method on a Node object to insert a child element before another child element. For example: ```javascript // Find the parent element with the ID "parent" const parent = document.getElementById("parent");

      // Find the second child element with the ID "child" const child = parent.querySelector("child");

      // Insert the child element before the second child element parent.insertBefore(child, parent.lastElementChild); ```

      I hope this helps! Let me know if you have any other questions.

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