将棋的なものを作ろうとして、最初のところです。
index.html
html
1<!DOCTYPE html> 2<html lang="ja"> 3 <head> 4 <meta charset="utf-8"> 5 <title>サイトタイトル</title> 6 <meta name="description" content="サイトキャプションを入力"> 7 <meta name="keywords" content="サイトキーワードを,で区切って入力"> 8 <link rel="stylesheet" href="sample.css"> 9 <script src="main.js" type="module"></script> 10 </head> 11 <body> 12 </body> 13</html>
main.js
javascript
1import { Constants } from "./Constants.js"; 2s = ""; 3s += " 9 8 7 6 5 4 3 2 1 \n"; 4s += "+---+---+---+---+---+---+---+---+---+\n"; 5for(let dan=1;dan<=9;dan++) { 6 for(let suji=9;suji>=1;suji--) { 7 s+="|"; 8 s+=" D "; 9 } 10 s+="|"; 11 s+=dan; 12 s+="\n"; 13 s+="+---+---+---+---+---+---+---+---+---+\n"; 14} 15console.log(s); 16console.log(Constants);
Constants.js
javascript
1export class Constants { 2 // 「先手」の定義 3 SENTE=1<<4; 4 // 「後手」の定義 5 GOTE =1<<5; 6 } 7
main.js:2 Uncaught ReferenceError: s is not defined at main.js:2:3
と、言われてしまいました。なぜでしょうか? 当該箇所で定義しているつもりでいたのですが......
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。