【发布时间】:2017-09-27 14:58:28
【问题描述】:
我正在尝试在我的 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"
]
}
]
}
【问题讨论】:
标签: javascript angular typescript npm swiper