如何让ZURB Foundation 6.4.1与Angular 4一起使用?

bem*_*med 4 zurb-foundation zurb-foundation-6 angular

我试图让ZURB Foundation 6.4.1与Angular 4一起工作,但我失败了.

我正在按照本教程http://shermandigital.com/blog/zurb-foundation-with-angular-cli/进行操作,但它仅适用于Foundation 6.3.

谢谢您的帮助.

fou*_*rix 7

试试这个:添加

@import "../node_modules/foundation-sites/assets/foundation";
Run Code Online (Sandbox Code Playgroud)

to style.scss

这应该可以解决您的问题

如果没有其他解决方案

  1. 安装基础:

    npm install foundation-sites --save

  2. 完成后转到.angular-cli.json(它是项目根目录中的隐藏文件)

  3. 添加此代码:

    "styles": [
    "../node_modules/foundation-sites/dist/foundation-flex.css",
    "styles.scss"
    ],
    "scripts": [
    "../node_modules/foundation-sites/vendor/jquery/dist/jquery.min.js",
    "../node_modules/foundation-sites/dist/foundation.min.js"
    ],
    
    Run Code Online (Sandbox Code Playgroud)
  4. 它应该工作但不适用于所有事情,例如模态.将此添加到您的app.ts或相关组件:代码:

    { import Component } from '@angular/core';
    declare var $:any
    
    @Component({
      selector: 'my-component',
      templateUrl: './my-component.html'
      // other stuff here
    });
    
    export class MyComponent implements OnInit {
      constructor() {}
    
      ngOnInit() {
        $(document).foundation();
      }
    }
    
    Run Code Online (Sandbox Code Playgroud)

  • 如果你现在有一个`angualr.json`文件,它应该改为``styles':["node_modules/foundation-sites/dist/css/foundation-flex.css","styles.scss"],"scripts": ["node_modules/jquery/dist/jquery.min.js","node_modules/foundation-sites/dist/js/foundation.min.js"],` (3认同)