任何人都可以指导如何将 Smooth Scroll Polyfill 与 Angular 2 CLI 一起使用。
我尝试在 polyfills.ts 中添加以下内容,但它会引发工作要求错误
require('smoothscroll-polyfill').polyfill();
然后我尝试添加
import 'smoothscroll-polyfill';
虽然它在构建期间没有抛出任何错误,但是当我在浏览器中运行项目时,它在控制台上显示以下错误:
ERROR TypeError: Failed to execute 'scroll' on 'Window': No function was found that matched the signature provided.
最佳答案
这是 Angular 2/4 解决方案:
安装 smoothscroll-polyfill - npm 安装 smoothscroll-polyfill
。
然后添加到你的 src/polyfills.ts 文件:
import smoothscroll from 'smoothscroll-polyfill/dist/smoothscroll.js';
smoothscroll.polyfill();
关于angular - 在 Angular 2 CLI 中使用 Smooth Scroll Polyfill,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43175331/