我想在我的angular 2网页上获得一个Slider,但无法使用ng2-slider-component获得。 在App的模块中,我在下面添加:
@NgModule({.......declarations: Ng2SliderComponent.........})
并在MyComponent&h; html中添加:
<ng2-slider
min="6"
max="23"
startValue="9"
endValue="21"
stepValue="2"
[normalHandlerStyle]="{ 'background-color': 'green'}"
[slidingHandlerStyle]="{
'border-radius': '9px',
'background-color': 'red'
}">
但是当我跑到上面时,我得到的错误低于2:
1)在cmd行上,当我运行npm start时,我得到以下错误:
ERROR in ./~/ng2-slider-component/ng2-slider.component.html
[0] Module parse failed: D:\Abc\Angular2\Projects\SPA4\Project\node_modules\ng2-slider-component\ng2-slider.component.html Unexpected token (1:0)
[0] You may need an appropriate loader to handle this file type.
[0] SyntaxError: Unexpected token (1:0)
[0] at Parser.pp$4.raise (D:\Abc\Angular2\Projects\SPA4\Project\node_modules\acorn\dist\acorn.js:2221:15)
[0] at Parser.pp.unexpected (D:\Abc\Angular2\Projects\SPA4\Project\node_modules\acorn\dist\acorn.js:603:10)
[0] at Parser.pp$3.parseExprAtom (D:\Abc\Angular2\Projects\SPA4\Project\node_modules\acorn\dist\acorn.js:1822:12)
[0] at Parser.pp$3.parseExprSubscripts (D:\Abc\Angular2\Projects\SPA4\Project\node_modules\acorn\dist\acorn.js:1715:21)
.........
.........
2)当我在浏览器上运行localhost:3000时,我得到以下错误:
main.js:18187 Uncaught Error: Cannot find module "./ng2-slider.component.html"(…)
webpackMissingModule @ main.js:18187
(anonymous function) @ main.js:18187
(anonymous function) @ main.js:18194
__webpack_require__ @ vendor.js:51
(anonymous function) @ main.js:74
__webpack_require__ @ vendor.js:51
(anonymous function) @ main.js:7
__webpack_require__ @ vendor.js:51
webpackJsonpCallback @ vendor.js:22
(anonymous function) @ main.js:1
请指导如何解决错误并在我的页面上获取滑块..
答案 0 :(得分:1)
目前ng2-slider-component似乎不支持webpack配置。我这样说是因为第34行在这里评论https://github.com/Bogdan1975/ng2-slider-component/blob/master/ng2-slider.component.ts