簡體   English   中英

node.js 在命令提示符下運行時不顯示代碼

[英]no code displaying when node.js runs in command prompt

我正在學習 java 腳本,但在運行代碼時遇到問題。

索引.html:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <h1>Hello World</h1>
    <script>src ="index.js"</script>
</body>
</html>

index.js:

// 
console.log('Hello World')

我嘗試從命令行運行節點,但沒有任何反應。 在此處輸入圖像描述

這是因為你不能插入這樣的腳本。 您包含錯誤的腳本。 你不能關閉第一個腳本標簽然后放 index.js 你必須像這樣輸入它:

是這樣的:

<script>src="index.js"</script>

把它像這樣:

<script src="index.js"></script>

暫無
暫無

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

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