質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.48%
JavaScript

JavaScriptは、プログラミング言語のひとつです。ネットスケープコミュニケーションズで開発されました。 開発当初はLiveScriptと呼ばれていましたが、業務提携していたサン・マイクロシステムズが開発したJavaが脚光を浴びていたことから、JavaScriptと改名されました。 動きのあるWebページを作ることを目的に開発されたもので、主要なWebブラウザのほとんどに搭載されています。

React.js

Reactは、アプリケーションのインターフェースを構築するためのオープンソースJavaScriptライブラリです。

Q&A

2回答

9545閲覧

index.htmlとindex.jsはどのような仕組みで連携しているのでしょうか?

otaks

総合スコア223

JavaScript

JavaScriptは、プログラミング言語のひとつです。ネットスケープコミュニケーションズで開発されました。 開発当初はLiveScriptと呼ばれていましたが、業務提携していたサン・マイクロシステムズが開発したJavaが脚光を浴びていたことから、JavaScriptと改名されました。 動きのあるWebページを作ることを目的に開発されたもので、主要なWebブラウザのほとんどに搭載されています。

React.js

Reactは、アプリケーションのインターフェースを構築するためのオープンソースJavaScriptライブラリです。

0グッド

1クリップ

投稿2018/10/06 01:24

編集2018/10/06 01:25

Reactを学習中です。

以下はcreate-react-appコマンドで作成した一連ファイル内にある
index.htmlですが、特にindex.jsを使うような記述が見当たりません。
index.htmlとindex.jsはどのような仕組みで連携しているのでしょうか?

html

1<!DOCTYPE html> 2<html lang="en"> 3 <head> 4 <meta charset="utf-8"> 5 <link rel="shortcut icon" href="%PUBLIC_URL%/favicon.ico"> 6 <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"> 7 <meta name="theme-color" content="#000000"> 8 <!-- 9 manifest.json provides metadata used when your web app is added to the 10 homescreen on Android. See https://developers.google.com/web/fundamentals/engage-and-retain/web-app-manifest/ 11 --> 12 <link rel="manifest" href="%PUBLIC_URL%/manifest.json"> 13 <!-- 14 Notice the use of %PUBLIC_URL% in the tags above. 15 It will be replaced with the URL of the `public` folder during the build. 16 Only files inside the `public` folder can be referenced from the HTML. 17 18 Unlike "/favicon.ico" or "favicon.ico", "%PUBLIC_URL%/favicon.ico" will 19 work correctly both with client-side routing and a non-root public URL. 20 Learn how to configure a non-root public URL by running `npm run build`. 21 --> 22 <title>React App</title> 23 </head> 24 <body> 25 <noscript> 26 You need to enable JavaScript to run this app. 27 </noscript> 28 <div id="root"></div> 29 <!-- 30 This HTML file is a template. 31 If you open it directly in the browser, you will see an empty page. 32 33 You can add webfonts, meta tags, or analytics to this file. 34 The build step will place the bundled scripts into the <body> tag. 35 36 To begin the development, run `npm start` or `yarn start`. 37 To create a production bundle, use `npm run build` or `yarn build`. 38 --> 39 </body> 40</html> 41

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

guest

回答2

0

試してみたところ、jsファイルが読み込まれているようでした。

console

1$ create-react-app test 2$ cd test 3$ yarn start

html

1<!DOCTYPE html> 2<html lang="en"> 3 <head> 4 <meta charset="utf-8"> 5 <link rel="shortcut icon" href="/favicon.ico"> 6 <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"> 7 <meta name="theme-color" content="#000000"> 8 <!-- 9 manifest.json provides metadata used when your web app is added to the 10 homescreen on Android. See https://developers.google.com/web/fundamentals/engage-and-retain/web-app-manifest/ 11 --> 12 <link rel="manifest" href="/manifest.json"> 13 <!-- 14 Notice the use of in the tags above. 15 It will be replaced with the URL of the `public` folder during the build. 16 Only files inside the `public` folder can be referenced from the HTML. 17 18 Unlike "/favicon.ico" or "favicon.ico", "/favicon.ico" will 19 work correctly both with client-side routing and a non-root public URL. 20 Learn how to configure a non-root public URL by running `npm run build`. 21 --> 22 <title>React App</title> 23 </head> 24 <body> 25 <noscript> 26 You need to enable JavaScript to run this app. 27 </noscript> 28 <div id="root"></div> 29 <!-- 30 This HTML file is a template. 31 If you open it directly in the browser, you will see an empty page. 32 33 You can add webfonts, meta tags, or analytics to this file. 34 The build step will place the bundled scripts into the <body> tag. 35 36 To begin the development, run `npm start` or `yarn start`. 37 To create a production bundle, use `npm run build` or `yarn build`. 38 --> 39 <script src="/static/js/bundle.js"></script><script src="/static/js/0.chunk.js"></script><script src="/static/js/main.chunk.js"></script></body> 40</html> 41

投稿2018/10/06 10:20

IshibashiTanaka

総合スコア152

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

0

create-react-appはwebpackを元に開発環境がパッケージされています。
試しにcreate-react-appで新しいプロジェクトを作ってnpm run ejectを打ってみると分かりやすいと思います。(※ejectしたあとは元に戻せないので新しいプロジェクトで試すことをお勧めします)
いろいろと設定ファイルがあらわになります。
これはcreate-react-appでパッケージされた設定ファイルたちです。
Reactアプリをさくっと作成するための設定がwebpackにてあらかじめされているため、アプリケーションbuild時にindex.htmlでJavaScriptを呼び出せています。

投稿2021/06/16 14:20

編集2021/06/16 14:21
runnynose

総合スコア497

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

まだベストアンサーが選ばれていません

会員登録して回答してみよう

アカウントをお持ちの方は

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.48%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問