编译器发现了意外的字符

发布于 2025-02-13 07:25:02 字数 292 浏览 1 评论 0原文

我正在研究React项目。 我要将一个组件导入到主组件中。

它具有传统的从“ react”;行导入。 但是突然,编译器显示了有关SyntaxError的消息。它说它发现了“意外的角色:'?'。

它发现这个角色在第1行中的地方: '?''?'import React from 'react';

Fortunately, I solved it but restarting compiler. 但是我想知道为什么会发生这种情况?是否有任何解决方案可以防止将来发生此类错误?

I am working on React project.
There is a component that I'm importing to the main component.

It has traditional import React from 'react'; line.
But suddenly compiler display a message about SyntaxError. It said that it found 'Unexpected character: '?'.

And a place that it found this character is in line 1:
'?''?'import React from 'react';

Fortunately, I solved it but restarting compiler.
But I want to know why did this happened? Is there any solutions that will prevent such errors in the future?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

身边 2025-02-20 07:25:02

由于它是在文件的开始,因此可能是字节订单标记;一些编辑器在编辑文件时会自动插入它。您使用什么编辑来进行更改?您最近是否使用其他任何东西打开它?

Since it's at the very beginning of the file, it might be the byte-order mark; some editors automatically insert it when you edit a file. What editor do you use to make changes? Did you recently open it using anything else?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文