[英]Unable to initialise Swiper in angular2 using npm
我正在尝试在我的angular2 + npm应用程序中使用swiper库,但是在尝试使用它时在构建时出现错误
错误是:
ERROR in vendor.95f9dda80938ded736ad.bundle.js from UglifyJs
Unexpected token: name (class_SwiperClass) [vendor.95f9dda80938ded736ad.bundle.js:16626,6]
我已将其包含在package.json中,并在组件中按以下方式使用它:
import Swiper from 'swiper/src/components/core/core-class';
ngAfterViewInit() {
let mySwiper : any = new Swiper('swiper-container', {
autoplay: 1000,
autoplayDisableOnInteraction : false,
speed: 400,
spaceBetween: 0,
pagination : ".swiper-pagination"
});
}
我的angular-cli配置如下:
{
"apps": [
{
"root": "src",
"outDir": "dist",
"assets": [
"assets",
"favicon.ico"
],
"index": "index.html",
"main": "main.ts",
"prefix": "app",
"styles": [
"../node_modules/swiper/dist/css/swiper.css"
],
"scripts": [
"../node_modules/swiper/dist/js/swiper.js"
]
}
]
}
我以这种方式在我的应用程序中使用Swiper:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.