html - AngularJS 风格不适用于新环境

标签 html css twitter-bootstrap angular angular-cli

我非常需要你。

我的应用程序在旧环境中运行,然后我将相同的源代码移动到新环境中。在我看来(猜测)即使源代码相同,样式表和图像也无法加载到新环境中。

非常感谢任何建议和帮助。

一些笔记,

  • 我。旧的工作环境是 NodeJs 6.11、Angular2 和 Angular -cli 1.0.0
  • 二。新的非工作环境是 NodeJs 8.4、Angular4 和 Angular -cli 1.4.3
  • iii.我把 Bootstrap 放在本地 “应用程序/css/bootstrap/dist/css/bootstrap.min.css”

预期的第一页带有样式和 Logo 。这仍然适用于旧环境: enter image description here

我在下面得到了新环境的简单标记。所有的样式和图像都消失了。右侧的 Firefox 控制台显示那些未加载。会不会跟新版本的Webpack有关? enter image description here

我的代码 - app.component.html enter image description here

我新的不工作的 package.json Package.json

我的index.html index.html which load the css

请帮忙。我是 HTML 和 AngularJS 的初学者。 如果我需要提供更多信息或需要升级某些模块,请告诉我。

最好的问候, 自动运行

最佳答案

将您的 css 样式、图像和 javascript 文件移动到最新版本的 angular-cli 中的 assets 文件夹中。

使用 Assets 文件夹中的图片,如下所示:

<img alt="image" class="img-circle" src="assets/iamges/logo.png">

并在 .angular-cli.json 中添加样式表和 javascript 文件

"styles": [
  <!-- "assets/css/style.css" from assets folder -->
  <!-- "../node_modules/bootstrap/dist/css/bootstrap.css" from node modules -->
  "styles.css"
],
"scripts": [
  <!-- "../node_modules/jquery/dist/jquery.js" from node modules js files -->,
  <!-- "../src/assets/js/javascript.js" from inside assets files-->
],

更改后重新启动您的元素。

关于html - AngularJS 风格不适用于新环境,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46375002/

相关文章:

javascript - jquery过滤器搜索应根据文本选择匹配的DIV

javascript - 如何使用 Javascript 调整 DIV 及其组件的大小

javascript - 在 chrome.tabs.executeScript 中的 javascript 函数中传递参数

javascript - 轮播导航触发 Bootstrap 的 Affix 函数

javascript - 自定义 Twitter Bootstrap 下拉菜单

javascript - 如何对 jQuery DataTables 中的数字列进行排序

reactjs - 不能在一行中设置三个元素

css - Pygments 在 pre 中向 HTML 添加空格

jquery - 在移动设备上移动内容上方的图像

javascript - rails : Anchor Tag to jump to location on same page without sending a new request and having to re-render the page