I am trying to use the swiper library in my angular2 + npm application but am having an error on build when trying to use it
The error is:
ERROR in vendor.95f9dda80938ded736ad.bundle.js from UglifyJs
Unexpected token: name (class_SwiperClass) [vendor.95f9dda80938ded736ad.bundle.js:16626,6]
I have included it in my package.json and am using it as follows in my component:
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"
});
}
My angular-cli configuration is as follows:
{
"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"
]
}
]
}
I'm using Swiper in my app in this way:
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.