Vue2移植Vue3报报错信息 Vue学习使用中遇到的一些报错记录。 <h1 class="title-article" id="articleContentId" style="box-sizing: border-box; outline: 0px; font-weight: 600; font-family: "PingFang SC", "Microsoft YaHei", SimHei, Arial, SimSun; font-size: 28px; overflow-wrap: break-word; color: rgb(34, 34, 38); word-break: break-all; background-color: rgb(255, 255, 255);">TypeError: routes.forEach is not a function</h1><p>原因:router路由数组格式不对</p><p><br></p><p>Catch all routes ("*") must now be defined using a param with a custom regexp.<br></p><p>原因:意思是捕获所有路由(“ ”)必须使用带有自定义正则表达式的参数来定义</p><p>Vue2里面可以这样写。</p><div style="color: rgb(212, 212, 212); background-color: rgb(30, 30, 30); font-family: Consolas, "Courier New", monospace; line-height: 19px; white-space: pre;"><span style="color: #9cdcfe;">path</span><span style="color: #9cdcfe;">:</span> <span style="color: #ce9178;">'/:catchAll(.*)'</span>,</div><p>Vue3必须写</p><div style="color: rgb(212, 212, 212); background-color: rgb(30, 30, 30); font-family: Consolas, "Courier New", monospace; line-height: 19px; white-space: pre;"><div style="line-height: 19px;"><div> {</div><div> <span style="color: #9cdcfe;">path</span><span style="color: #9cdcfe;">:</span> <span style="color: #ce9178;">'/:catchAll(.*)'</span>,</div><div> <span style="color: #9cdcfe;">name</span><span style="color: #9cdcfe;">:</span> <span style="color: #ce9178;">'404'</span>,</div><div> <span style="color: #dcdcaa;">component</span><span style="color: #9cdcfe;">:</span> () <span style="color: #569cd6;">=></span> <span style="color: #569cd6;">import</span>(<span style="color: #ce9178;">'@/pages/exception/404'</span>),</div><div> },</div></div></div><p><br></p><p><br></p><p><br></p><p><br></p><p><br></p> Edit Save Comments: 留言