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