第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機(jī)立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

import 語句給出語法錯誤,指出“無法在模塊外部使用 import 語句”

import 語句給出語法錯誤,指出“無法在模塊外部使用 import 語句”

繁花不似錦 2022-09-02 17:19:57
我是Web開發(fā)的新手,這只是我創(chuàng)建的一個簡單的代碼,用于測試我安裝的新文本編輯器,我在嘗試導(dǎo)入react時遇到了此錯誤,因為我遇到了一些其他錯誤,例如;類型錯誤: 無法讀取未定義的屬性“createElement”請問,我該如何解決這個問題?導(dǎo)入語句有誤嗎?import React, { Fragment } from 'react';console.log("Testing");var document;//made this declaration because I got a document undefined error document.createElement("p"):const p = document.createElement("p")p.innerHTML = "This is to test the javascript";const body = document.querySelector("body");body.insertBefore(p,body.childNode[-1]);<!DOCTYPE html><html><head>  <title>Testing vs code</title>  <link rel="stylesheet" type="text/css" href="styles.css"/>  </head><body>  <h1>Testing the vscode html preview package</h1>  <h2>Hello</h2>  <script type="module" src="js-prac.js"></script></body></html>
查看完整描述

3 回答

?
隔江千里

TA貢獻(xiàn)1906條經(jīng)驗 獲得超10個贊

我知道你想用 React 創(chuàng)建一個簡單的應(yīng)用程序。我建議你先讀一 https://kentcdodds.com/blog/how-to-react,然后再讀這個:https://reactjs.org/tutorial/tutorial.html

可以通過在開始時導(dǎo)入腳本來創(chuàng)建 react 應(yīng)用程序,但這不是構(gòu)建 react 應(yīng)用程序的推薦方法。

完成上述帖子后,請在您選擇的平臺上找到您選擇的好教程,無論是基于博客還是基于視頻。我可以舉出一些像udemy,前端大師,復(fù)數(shù)視覺,還有更多。


查看完整回答
反對 回復(fù) 2022-09-02
?
LEATH

TA貢獻(xiàn)1936條經(jīng)驗 獲得超7個贊

看看 ReactJS 網(wǎng)站。


你應(yīng)該使用 Node 包管理器創(chuàng)建 React 應(yīng)用程序 npx create-react-app appName


或者應(yīng)該將反應(yīng)腳本鏈接到您的html


<script src="https://unpkg.com/react@16/umd/react.development.js"></script> 

<script src="https://unpkg.com/react-dom@16/umd/react-dom.development.js"></script>


也不能重新定義文檔對象。這將引用您的網(wǎng)頁,您可以使用文檔對象訪問元素或 DOM(文檔對象模型)。


查看完整回答
反對 回復(fù) 2022-09-02
?
犯罪嫌疑人X

TA貢獻(xiàn)2080條經(jīng)驗 獲得超4個贊

根據(jù) https://reactjs.org/docs/add-react-to-a-website.html,您需要在導(dǎo)入腳本之前將以下兩行添加到HTML文件中:


<script src="https://unpkg.com/react@16/umd/react.development.js" crossorigin></script> 

<script src="https://unpkg.com/react-dom@16/umd/react-dom.development.js" crossorigin></script>

我不確定模塊加載是否會按照你想要的方式工作,而不使用像Create React App這樣的東西。您可以刪除導(dǎo)入語句,并且仍然可以在腳本中引用 React 和 ReactDOM。


例如:


'use strict';


const e = React.createElement;


class LikeButton extends React.Component {

  constructor(props) {

    super(props);

    this.state = { liked: false };

  }


  render() {

    if (this.state.liked) {

      return 'You liked comment number ' + this.props.commentID;

    }


    return e(

      'button',

      { onClick: () => this.setState({ liked: true }) },

      'Like'

    );

  }

}


// Find all DOM containers, and render Like buttons into them.

document.querySelectorAll('.like_button_container')

  .forEach(domContainer => {

    // Read the comment ID from a data-* attribute.

    const commentID = parseInt(domContainer.dataset.commentid, 10);

    ReactDOM.render(

      e(LikeButton, { commentID: commentID }),

      domContainer

    );

  });


查看完整回答
反對 回復(fù) 2022-09-02
  • 3 回答
  • 0 關(guān)注
  • 130 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號