![](/img/trans.png)
[英]React - Module parse failed: Unexpected Token. You may need an appropriate loader to handle this file type
[英]React/Zustand - Module parse failed: Unexpected token. You may need an appropriate loader to handle this file type
我在我的 react 應用程序中遇到錯誤,不確定錯誤本身來自何處,並且代碼似乎干凈且沒有錯誤,並且遵循最佳實踐。
Error Log
Failed to compile.
./src/components/CourseList.jsx 74:14
Module parse failed: Unexpected token (74:14)
You may need an appropriate loader to handle this file type.
| columnNumber: 17
| }
> }, course?.title), /*#__PURE__*/React.createElement("button", {
| className: "delete-btn",
| onClick: function onClick() {
courseList.jsx
<span className="course-title">{course?.title}</span>
<button
className="delete-btn"
onClick={() => {
removeCourse(course.id);
}}
>
Delete Course
</button>
在調試了很長時間並嘗試了很多次之后,我后來得到了問題所在,但不明白為什么這本身就是引發問題的原因。
我只需將{course?.title}
更改為{course.title}
代碼就可以成功編譯而沒有問題。 因此,刪除?
讓它工作。
我希望這可以幫助那里的人。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.