Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angular/26.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
引导程序不适用于我的Angular项目_Angular_Angular Cli_Angular Ui Bootstrap_Angular6_Angular Cli V6 - Fatal编程技术网

引导程序不适用于我的Angular项目

引导程序不适用于我的Angular项目,angular,angular-cli,angular-ui-bootstrap,angular6,angular-cli-v6,Angular,Angular Cli,Angular Ui Bootstrap,Angular6,Angular Cli V6,我已经使用以下步骤将引导包含到我的Angular项目中 使用cli创建了一个项目 npm安装bootstrap@3jquery—保存 然后像往常一样将脚本和样式路径添加到我的索引文件中 该样式不应用于我的页面。还有什么我必须做的吗。我正在从索引页添加HTML代码片段 项目 ewreeew 测试按钮 我怀疑问题出在文件的路径上。包含依赖项的最佳方法是将样式和脚本数组添加到“angular.json”文件的构建目标中。您可以使用绝对路径而不是相对路径,因此您应该使用“node\u modules

我已经使用以下步骤将引导包含到我的Angular项目中

  • 使用cli创建了一个项目
  • npm安装bootstrap@3jquery—保存
  • 然后像往常一样将脚本和样式路径添加到我的索引文件中
  • 该样式不应用于我的页面。还有什么我必须做的吗。我正在从索引页添加HTML代码片段

    
    项目
    ewreeew
    测试按钮
    
    我怀疑问题出在文件的路径上。包含依赖项的最佳方法是将样式和脚本数组添加到“angular.json”文件的构建目标中。您可以使用绝对路径而不是相对路径,因此您应该使用“node\u modules/”而不是“./node\u modules/”

    以下是构建目标的示例:

     "build": {
       "builder": "@angular-devkit/build-angular:browser",
       "options": {
         "styles": [                  
           "src/styles.css",
           "node_modules/bootstrap/dist/css/bootstrap.min.css"
           "node_modules/bootstrap/dist/css/bootstrap-theme.min.css"   
         ],
         "scripts": [
           "node_modules/jquery/dist/jquery.min.js",
           "node_modules/bootstrap/dist/js/bootstrap.min.js"
         ]
      }
    

    您可能已经包含了jQuery,但我在您的示例中没有看到它。我在这里添加了它以防万一。

    将引导文件添加到全局style.css文件中,如下所示:-

    @import "~bootstrap/dist/css/bootstrap.css"; 
    

    你能展示你如何在索引中添加脚本/样式吗?这是html代码项目Hmmm,你应该用这些代码编辑你的问题。您使用的是哪个版本的Angular?我有类似的问题,但您使用的是哪台服务器(后端)?如果您正在使用的是node(express),请尝试在应用程序中包含公用文件夹(app.use)