javascript - 如何以角度添加额外的加载器?
问题描述
我是 Angular 的新手,我尝试将 .js 文件导入到我的 app.component.ts,该文件是 npm 包的一部分
import { Component } from '@angular/core';
import { ListenerScroll } from '../utils/listener-scroll';
@Component({...});
但我有这个错误:
Module parse failed: Unexpected token (8:28)
File was processed with these loaders:
* ./node_modules/@angular-devkit/build-angular/src/babel/webpack-loader.js
* ./node_modules/@ngtools/webpack/src/ivy/index.js
* ./node_modules/source-map-loader/dist/cjs.js
You may need an additional loader to handle the result of these loaders.
|
| export class ListenerScroll {
> static listenerScrollAdded = false;
| static listenerScroll = [];
|
我知道静态属性并非在所有浏览器中都可用,因此我必须“转换” .js 文件,在 webpack 中您可以添加 babel 并将现代语言转换为浏览器可以读取的语言,如何在角度上做类似的事情?
谢谢您的帮助!:)
解决方案
推荐阅读
- laravel - PurgeCSS 移除第三方库 css - Laravel Mix / TailwindCSS
- react-navigation - 如何使用 React Navigation 5.x 在不同的选项卡中重置堆栈
- java - 如何使用 Java 检查 Google Cloud Storage 中是否存在文件夹?
- html - 为什么 html 地图和区域在移动设备上不起作用?
- presto - 如何在 Presto 中将日、月、年字段组合成日期?
- python - 从最深层次开始的块嵌套列表
- hashicorp-vault - 带有 TLS HA 和 Raft 的 k8s 上的 Vault
- android - 用Fragment替换Activity中的FrameLayout并不会替换整个FrameLayout
- email - WIX 页面 UTM_SOURCE
- python - 如何处理 403 Client Error: Forbidden for url?