你必須在你的app.js文件中指定你的靜態內容的位置,當index.html將呈現時,服務器將文件提供給瀏覽器的位置。
for example if i have following directory structure
ROOT
|
---public
| |
| ----css
| | |
| | ----style.css
| | |
| |
| ----js
| | |
| | ----script.js
| | |
| |
| ----images
| |
|
|
---app.js
|
---index.html
|
Browser requested urls format are
css - > <link href="/css/style.css" rel="stylesheet" type="text/css" />
js - > <script type="text/javascript" src="/js/script.js"></script>
after that you have to add following code in your app.js file;
app.use(express.static(__目錄名+ '/公共'));
if express is not installed in your system install it form cmd using command
NPM安裝明示
add following line of code in app.js
變種快遞=要求( '表示') ,應用程式=快遞();
投票反對的人可以告訴我原因嗎? – LiJung