[英]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.