我目前正在使用角度为2的MEAN堆栈。

我无法找出问题所在。

我正在获取未完全加载的网站。不知道它的CSS问题。

这是带有为Angular 2应用程序配置的端口的文件夹结构。

但是,当我尝试访问页面时:http://my_ip:9200/admin/login我没有完全加载CSS。即)页面无法完全加载。

https://imgur.com/a/ByeLK

/var/www/html/Express/Local-MEAN-dev/index.js

...
const port = process.env.PORT || 9000;
....
//Start Server: Listen on port 9000
app.listen(port, () => {
    console.log('Listening on port ' + port);
});


package.json

{
  "name": "mean-ang2",
  "version": "1.0.0",
  "description": "MEAN Stack with Angular 2",
  "main": "index.js",
  "scripts": {
    "start": "node index.js",
    "build": "cd client && ng build --prod"
  },
"repository": {
"type": "git",
"url": ""
   },
 "keywords": [
   ..
 ],
"author": "",
"license": "ISC",
"bugs": {
  "url": ""
},
"homepage": "",
"dependencies": {
  ...
},
"devDependencies": {
  "@angular/cli": "^1.2.3"
}
}


在/ var / www / html / Express / Local-MEAN-dev / admin下

是我有我的角度2代码的地方。

<!doctype html>
<html>

<head>
  <meta charset="utf-8">
  <title>Food4Smiles</title>
  <base href="/admin">
  <!--<link rel="stylesheet" href="https://bootswatch.com/flatly/bootstrap.css">-->
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="icon" type="image/x-icon" href="assets/static/hmicon.png">
</head>

<body>
  <app-root></app-root>
  <script src="https://code.jquery.com/jquery-3.2.1.js" integrity="sha256-DZAnKJ/6XZ9si04Hgrsxu/8s717jcIzLy3oi35EouyE=" crossorigin="anonymous"></script>
  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
</body>

</html>


要为管理员配置自定义端口,我已经编辑了以下文件:

\ Local-MEAN-dev \ admin \ node_modules \ @angular \ cli \ commands \ serve.js

const defaultPort = process.env.PORT ||9200;

最佳答案

在head标签中添加bootstrap css链接。

<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">

10-06 08:25