簡體   English   中英

未捕獲的 SyntaxError 無法在模塊外使用 import 語句

[英]Uncaught SyntaxError Cannot use import statement outside a module

我在 react-iframe 中遇到了這個錯誤。 我應該如何解決?

版本:react@16.13.1 react-iframe@1.8.0 (如果我需要添加更多細節,請告訴我)

  import Iframe from 'react-iframe
  import React, { Component } from "react";

  class TableList extends Component {
  render{
  return(
  <div>
    <Iframe url="some url"
    width="100%"
    height="1000"
    id="myId"
    // className="embed-responsive-item"
    display="initial"
    position="relative"
    X-Frame-Options="deny"
    />

  </div>
)
}
}
export default TableList;

`

所以不確定這是否是復制/粘貼錯誤,但所有導入必須在兩個引號之間定義:

  import Iframe from 'react-iframe'
  import Iframe from 'react-iframe';
  import React, { Component } from "react";

  class TableList extends React.Component {
    render() {
    return(
      <div>
        <Iframe url="some URL"
          width="100%"
          height="1000"
          id="myId"
          // className="embed-responsive-item"
          display="initial"
          position="relative"
          X-Frame-Options="deny"
        />
     </div>
   )
  }
}
export default TableList;

嘗試這個。 您忘記了 iframe 導入中的單引號和渲染方法中的括號。 render 是一種方法,所以它應該有()括號我的朋友。

希望它會幫助你。 快樂編碼!

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM