[英]Add script js to an Angular 9 project
我尝试将 script.js 添加到 angular.json 并在一个组件中使用它,这样对于那些可以建议将脚本标签添加到我的 html 文件的人来说不起作用使我的脚本工作。 谢谢
这是我的脚本:
$('.owl-carousel').owlCarousel({
loop:true,
margin:10,
dots:false,
nav:true,
mouseDrag:false,
autoplay:true,
animateOut: 'slideOutUp',
responsive:{
0:{
items:1
},
600:{
items:1
},
1000:{
items:1
}
}
});
文件.html:
<header>
<div class="owl-carousel owl-theme">
<div class="item">
<img src="https://cdn.pixabay.com/photo/2017/10/24/10/30/business-2884023_960_720.jpg" alt="images not found">
<div class="cover">
<div class="container">
<div class="header-content">
<div class="line"></div>
<h2>Teimagine Digital Experience with</h2>
<h1>Start-ups and solutions</h1>
<h4>We help entrepreneurs, start-ups and enterprises shape their ideas into products</h4>
</div>
</div>
</div>
</div>
<div class="item">
<img src="https://cdn.pixabay.com/photo/2016/03/09/09/22/workplace-1245776_960_720.jpg" alt="images not found">
<div class="cover">
<div class="container">
<div class="header-content">
<div class="line animated bounceInLeft"></div>
<h2>Reimagine Digital Experience with</h2>
<h1>Intelligent solutions</h1>
<h4>We help entrepreneurs, start-ups and enterprises shape their ideas into products</h4>
</div>
</div>
</div>
</div>
</header>
方式一:
请参阅 angular-cli.json(使用 angular 6+ 时为 angular.json)文件中的脚本。
"scripts": [ "../path" ];
然后添加 typings.d.ts (如果该文件尚不存在,则在 src 中创建此文件)
declare var variableName:any;
将其导入您的文件中
import * as variable from 'variableName';
参考https://stackoverflow.com/a/44817445/9640128
方式二:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.