Bind Vue on body or others element

后端 未结 2 1498
暖寄归人
暖寄归人 2020-12-16 13:07

I\'ve seen many times Vue instance is bind on body tag. Other times this is bind on a div id

I\'m asking when i should use body

相关标签:
2条回答
  • 2020-12-16 13:51

    The accepted answer is correct: binding the main Vue instance on body element is really not recommended!

    For more information:

    • Why it's not recommended to render to <body> element (related to React, but similar principle applies to Vue too)
    0 讨论(0)
  • 2020-12-16 13:53

    You should never use the body tag. In fact, it raises a warning to use the body tag.

    Added a warning when mounting the root instance to body or html. This is no longer recommended in 2.0.

    This is from the release notes, anyways it's incorrect, it raises an error.

    0 讨论(0)
提交回复
热议问题