【问题标题】:How to use external js File function in angular web application如何在 Angular Web 应用程序中使用外部 js 文件功能
【发布时间】:2019-03-29 15:03:14
【问题描述】:

我只想使用外部 js 文件在我的 Angular Web 应用程序中构建动画。

在 W3C 网站上我发现了这个: https://www.w3schools.com/howto/tryit.asp?filename=tryhow_js_image_compare

我只想在我的 Angular 应用程序中使用这个 js 文件,但它不起作用。

 $('.owl-carousel').owlCarousel({
  loop: true,
  margin: 10,
  nav: false,
  autoplay: true,
  autoplayTimeout: 3000,
  autoplayHoverPause: true,
  dots: false,
  responsive: {
    0: {
      items: 1
    },
    600: {
      items: 3
    },
    1000: {
      items: 5
    }
  }
})

在外部 js 文件中有这个功能,我如何在我的 Angular Web 应用程序中使用这个功能。

有人可以给我一些建议吗?

【问题讨论】:

    标签: angular external-js


    【解决方案1】:

    正确的做法是将代码转换成 Typescript。 您应该逐步实现 Angular 逻辑。

    您可以实现一个指令并在需要时调用它。 https://angular.io/guide/attribute-directives

    【讨论】:

    • 但是我不想更改外部js文件中的任何代码。
    猜你喜欢
    • 1970-01-01
    • 2018-11-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-05-19
    • 2020-06-11
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多