cannot appear as a descendant of

前端 未结 11 525
执念已碎
执念已碎 2021-01-30 04:36

I\'m seeing this. It\'s not a mystery what it is complaining about:

Warning: validateDOMnesting(...): 
cannot appear as a descendant of

. See

11条回答
  •  别那么骄傲
    2021-01-30 05:16

    This is a constraint of browsers. You should use div or article or something like that in the render method of App because that way you can put whatever you like inside it. Paragraph tags are limited to only containing a limited set of tags (mostly tags for formatting text. You cannot have a div inside a paragraph

    is not valid HTML. Per the tag omission rules listed in the spec, the

    tag is automatically closed by the

    tag, which leaves the

    tag without a matching

    . The browser is well within its rights to attempt to correct it by adding an open

    tag after the

    :

    You can't put a

    inside a

    and get consistent results from various browsers. Provide the browsers with valid HTML and they will behave better.

    You can put

    inside a
    though so if you replace your

    with

    and style it appropriately, you can get what you want.

提交回复
热议问题