最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - index.js:1 Warning: validateDOMNesting(...): <ul> cannot appear as a descendant of <p>

programmeradmin0浏览0评论
index.js:1 Warning: validateDOMNesting(...): <h6> cannot appear as a descendant of <p>.
index.js:1 Warning: validateDOMNesting(...): <ul> cannot appear as a descendant of <p>.
index.js:1 Warning: validateDOMNesting(...): <form> cannot appear as a descendant of <p>.

What is the cause of these errors?

index.js:1 Warning: validateDOMNesting(...): <h6> cannot appear as a descendant of <p>.
index.js:1 Warning: validateDOMNesting(...): <ul> cannot appear as a descendant of <p>.
index.js:1 Warning: validateDOMNesting(...): <form> cannot appear as a descendant of <p>.

What is the cause of these errors?

Share Improve this question edited Nov 25, 2020 at 3:35 Obsidian Age 42.5k11 gold badges53 silver badges76 bronze badges asked Nov 25, 2020 at 3:27 MelisMelis 411 silver badge3 bronze badges
Add a ment  | 

3 Answers 3

Reset to default 3

<p> is used to denote a paragraph of text, and it makes no logical sense to include a heading, list or form inside of a paragraph. As such, <h6>, <ul> and <form> are not valid children of the <p> tag. The only permitted content for <p> tags is phrasing content.

The only phrasing content (and the only valid children of the <p> tag) are <abbr>, <audio>, <b>, <bdo>, <br>, <button>, <canvas>, <cite>, <code>, <mand> (obsolete), <data>, <datalist>, <dfn>, <em>, <embed>, <i>, <iframe>, <img>, <input>, <kbd>, <keygen> (obsolete), <label>, <mark>, <math>, <meter>, <noscript>, <object>, <output>, <picture>, <progress>, <q>, <ruby>, <samp>, , <select>, <small>, <span>, <strong>, <sub>, <sup>, <svg>, <textarea>, <time>, <var>, <video>, <wbr> and plain text (not only consisting of white spaces characters).

you may have called mui Typography control without variant somewhere which is converted as a P tag on DOM render. either give variant or remove Typography control, it applicable for all.

Find elemnt by run this code in console

document.querySelectorAll(" p * ul ")
<CustomElement tag={"p"} />
// OR
<Text as="p" />

change with

<CustomElement tag={"div"} />
// OR
<Text as="div" />

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论