【问题标题】:Line7:1: parsing error: 'import' and 'export' may only appear at the top levelLine7:1:解析错误:“import”和“export”可能只出现在顶层
【发布时间】:2021-02-02 06:02:19
【问题描述】:

我的代码抛出错误

parsing error: 'import' and 'export' may only appear at the top level

可能是什么问题?我的代码:

import React from "react";

function Address(){

let Adress = "96 rue de la bonheur,Casa";
return(

<p>MyAddress:<br/>{Adress}</p>

)
export default Address;
}

【问题讨论】:

  • 错误消息说,它不喜欢你几乎最后一行的导出语句。您只能在函数之外使用导入和导出。

标签: reactjs import components


【解决方案1】:

试试这个

import React from "react";

function Address(){

let Adress = "96 rue de la bonheur,Casa";
return(
<div>

  {Adress}
</div>
) }
export default Address; 

【讨论】:

    猜你喜欢
    • 2021-08-08
    • 2020-06-05
    • 2021-12-14
    • 1970-01-01
    • 1970-01-01
    • 2017-05-07
    • 2017-05-16
    • 2021-03-06
    相关资源
    最近更新 更多