所以我正在关注这个 udemy 课程https://www.udemy.com/course/become-a-wordpress-developer-php-javascript/我现在应该制作一个实时搜索栏,但最终我得到一个错误这完全没有意义所以首先我的错误:Uncaught Error: Module build failed (from ./node_modules/babel-loader/lib/index.js):SyntaxError: C:\Users\mathi\Local Sites\test-site-2\app\public\wp-content\themes\Test_site2\js\modules\Search.js: Unexpected token (59:12)[0m [90m 57 | [39m[32m ${combinedResults.map(item => `<li><a href="${item.link}">${item.title.rendered}</a></li>`).join('')} [39m[0m[0m [90m 58 | [39m[32m ${combineResults.lenght ? '</ul>' : ''}`[39m)[33m;[39m[0m[0m[31m[1m>[22m[39m[90m 59 | [39m [33m<[39m[33m/[39m[33mdiv[39m[33m>[39m[0m[0m [90m | [39m [31m[1m^[22m[39m[0m[0m [90m 60 | [39m[0m[0m [90m 61 | [39m [33m<[39m[33mdiv[39m [36mclass[39m[33m=[39m[32m"one-third"[39m[33m>[39m[0m[0m [90m 62 | [39m [33m<[39m[33mh2[39m [36mclass[39m[33m=[39m[32m"search-overlay__section-title"[39m[33m>[39m[33mPrograms[39m[33m<[39m[33m/[39m[33mh2[39m[33m>[39m[0m at Parser.raise (C:\Users\mathi\Local Sites\test-site-2\node_modules\@babel\parser\lib\index.js:6344:17) at Parser.unexpected (C:\Users\mathi\Local Sites\test-site-2\node_modules\@babel\parser\lib\index.js:7659:16) at Parser.parseExprAtom (C:\Users\mathi\Local Sites\test-site-2\node_modules\@babel\parser\lib\index.js:8828:20) at Parser.parseExprSubscripts (C:\Users\mathi\Local Sites\test-site-2\node_modules\@babel\parser\lib\index.js:8413:23) at Parser.parseMaybeUnary (C:\Users\mathi\Local Sites\test-site-2\node_modules\@babel\parser\lib\index.js:8393:21) at Parser.parseExprOps (C:\Users\mathi\Local Sites\test-site-2\node_modules\@babel\parser\lib\index.js:8280:23)
2 回答
繁星点点滴滴
TA贡献1803条经验 获得超3个赞
第 58 - 65 和 69 行 _ 'length' 的拼写错误
${combineResults.lenght ? '</ul>' : ''}`);
_ 看起来好像整个字符串应该在第 58 行下方的一行终止
所以
${combineResults.lenght ? '</ul>' : ''}`);
</div>
应该读
${combineResults.length ? '</ul>' : ''}
</div>`);
蝴蝶刀刀
TA贡献1801条经验 获得超8个赞
combineResults 应该是结果,如果您像课程 results.generalInfo.length 一样创建自定义 rest-api 并用不同的帖子类型程序、教授、校园、活动替换 generalInfo
添加回答
举报
0/150
提交
取消