- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我正在尝试使用带有 Angular 2的整页,
将其导入我的 app.module.ts 时出现以下错误。
"(SystemJS) Unexpected token <
SyntaxError: Unexpected token <
at eval (<anonymous>)
at Object.eval (http://localhost:3000/app/app.module.js:16:22)
at eval (http://localhost:3000/app/app.module.js:40:4)
at eval (http://localhost:3000/app/app.module.js:41:3)
at eval (<anonymous>)
Evaluating http://localhost:3000/node_modules/ng2-fullpage
Evaluating http://localhost:3000/app/app.module.js
Evaluating http://localhost:3000/main.js
Error loading http://localhost:3000/main.js"
以下是我的文件:
systemjs.config.js
(function (global) {
System.config({
paths: {
// paths serve as alias
'npm:': 'node_modules/'
},
// map tells the System loader where to look for things
map: {
// our app is within the app folder
app: 'app',
// angular bundles
'@angular/core': 'npm:@angular/core/bundles/core.umd.js',
'@angular/common': 'npm:@angular/common/bundles/common.umd.js',
'@angular/compiler': 'npm:@angular/compiler/bundles/compiler.umd.js',
'@angular/platform-browser': 'npm:@angular/platform-browser/bundles/platform-browser.umd.js',
'@angular/platform-browser-dynamic': 'npm:@angular/platform-browser-dynamic/bundles/platform-browser-dynamic.umd.js',
'@angular/http': 'npm:@angular/http/bundles/http.umd.js',
'@angular/router': 'npm:@angular/router/bundles/router.umd.js',
'@angular/forms': 'npm:@angular/forms/bundles/forms.umd.js',
// '@jquery':'npm:jquery/jquery.min.js',
// other libraries
'rxjs': 'npm:rxjs',
'angular-in-memory-web-api': 'npm:angular-in-memory-web-api/bundles/in-memory-web-api.umd.js',
'ng2-fullpage': 'npm:ng2-fullpage',
// 'jquery': 'npm:jquery/dist/jquery.js',
'fullpage.js': 'npm:fullpage.js/jquery.fullPage.js'
},
// packages tells the System loader how to load when no filename and/or no extension
packages: {
app: {
// format:'register',
defaultExtension: 'js'
},
rxjs: {
defaultExtension: 'js'
}
}
});
})(this);
app.module.ts
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import {HttpModule} from '@angular/http';
import {routing} from './app.routing';
import {NavbarComponent} from './components/navbar/navbar.component';
import { MnFullpageDirective } from 'ng2-fullpage';
import {MnFullpageService} from 'ng2-fullpage';
import { AppComponent } from './app.component';
import { ResumeComponent } from './components/resume/resume.component';
import { AboutComponent } from './components/about/about.component';
import {HomeComponent} from './components/home/home.component';
@NgModule({
imports: [ BrowserModule,HttpModule, routing ],
declarations: [ AppComponent, ResumeComponent, AboutComponent, HomeComponent, NavbarComponent,
MnFullpageDirective
],
bootstrap: [ AppComponent ],
providers: [MnFullpageService]
})
export class AppModule { }
index.html
<!DOCTYPE html>
<html>
<head>
<title>Nakul Chawla</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://bootswatch.com/cyborg/bootstrap.min.css" />
<link rel="stylesheet" href="../node_modules/bootstrap/dist/css/bootstrap.min.css" />
<link rel="stylesheet" href="styles.css">
<!--<link rel="stylesheet" href="../node_modules/fullpage.js/dist/jquery.fullpage.css" />-->
<!--<script src="node_modules/jquery/jquery.js"></script>-->
<!-- Polyfill(s) for older browsers -->
<script src="node_modules/core-js/client/shim.min.js"></script>
<script src="node_modules/zone.js/dist/zone.js"></script>
<script src="node_modules/systemjs/dist/system.src.js"></script>
<script src="systemjs.config.js"></script>
<script src="node_modules/jquery/dist/jquery.min.js"></script>
<script src="node_modules/bootstrap/dist/js/bootstrap.min.js"></script>
<script>
System.import('main.js').catch(function(err){ console.error(err); });
</script>
</head>
<body>
<base href="/">
<my-app>Loading AppComponent content here ...</my-app>
</body>
</html>
我正在从引用 plunkr 的 npm 页面获取帮助:
npm 包
http://embed.plnkr.co/1p9zKp4CNI1HncAh1h9m
plunkr我已向其他堆栈溢出页面寻求帮助并尝试了所有方法,但错误似乎仍然存在。
我在 stackoverflow 上发布了该问题的另一个变体,这两个错误都有相同的问题。
Unable to load ng2-fullpage in my angular-2 quickstart app
我不知道如何解决这个问题,现在尝试了一切。
提前致谢。
最佳答案
肯定有很多问题可能导致此错误。我在将 SystemJS 与网络服务器(例如 live-server)结合使用时得到了它。为单页 Web 应用程序提供了一个方便的功能,即将所有不存在的文件路由到项目的 index.html。因此,如果 SystemJS 尝试解析未安装的依赖项,网络服务器将显示通常以 <!DOCTYPE html>
开头的 index.html。 。这可能是意想不到的<
错误中提到。
jspm install my_dependency
安装缺少的依赖项.关于javascript - 错误: (SystemJS) Unexpected token < SyntaxError: Unexpected token < at eval (<anonymous>) Angular 2,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42326648/
在我看来 eval()受到与 goto 相同的蔑视。由 eval ,我的意思是将字符串作为代码执行的函数,如在 PHP、Python、JavaScript 等中看到的。是否有使用 eval() 的情况
关闭。这个问题需要多问focused 。目前不接受答案。 想要改进此问题吗?更新问题,使其仅关注一个问题 editing this post . 已关闭 9 年前。 Improve this ques
我有几十个条件(例如,foo > bar)需要在 DataFrame 的 ~1 MM 行上进行评估,最简洁的方法编写此代码是为了将这些条件存储为字符串列表,并创建 bool 结果的 DataFrame
我正在创建一种编译为字节码并在自定义 VM 上运行的小型语言,其架构在很大程度上受到了我所阅读的有关 Python 和 Lua 的影响。有两个堆栈 - 一个存储函数参数、局部变量和临时值的数据堆栈,以
我正在尝试运行此代码: var aaa = await page.$$eval(selector, list => (list, value) => { return reso
我知道标题听起来很复杂,但为了保持动态,这是有目的的;) 示例(请注意,假定这些示例代码位于外部 eval 内) //Ex1 this works eval('function test (){}')
这是交易,我们有一个很大的 JS 库需要压缩,但是 YUI compressor如果发现“eval”语句,它不会完全压缩代码,因为担心它会破坏其他东西。这很好,但是我们确切地知道什么正在被评估,所以我
每门计算机科学类(class)中都讲授过这一点,并且在许多书籍中都写到程序员不应使用 GoTo。甚至还有一个 xkcd关于它的漫画。我的问题是我们是否达到了可以对 Eval 说同样的事情的地步? Go
这两种方法中的一种是否必须被优先使用,还是仅取决于口味? #!/usr/bin/env perl use warnings; use strict; use DBI; my $db = 'sqlite
如果存在“eval()”,uglify 不会破坏变量。命令行: uglifyjs script/script.js --compress --mangle --unsafe/path/to/scrip
我刚刚开始使用 Julia。我正在尝试使用 eval(在 Julia 中)来在函数中定义一组变量。假设我想将 v1 设置为 2: function fun_test(varargs...) v1
这个问题在这里已经有了答案: When is JavaScript's eval() not evil? (27 个答案) 关闭2 年前。 我从未遇到过需要 eval() 的情况。 人们常常说 []
这个问题在这里已经有了答案: "Variable" variables in JavaScript (9 个回答) Use dynamic variable names in JavaScript
好的 - 我有一个非常具体的案例,我需要使用 eval()。在人们告诉我我根本不应该使用 eval() 之前,让我透露一下我知道 eval 的性能问题、安全问题和所有这些问题。我在非常狭窄的情况下使用
我的问题是关于 JavaScript 闭包和 Eval() 函数。 我有一些看起来像这样的代码,还有一些其他 jQuery 插件相关的代码没有显示。如果需要,我可以用更多代码更新问题。 var _Cu
...或者有更好的方法来实现记忆化吗? Function.memoize = function(callableAsString) { var r = false, callable,
当我尝试在jmeter中执行以下代码时: import org.json.JSONArray; import org.json.JSONObject; String jsonString = prev
根据Mozilla docs为了使用 eval 执行函数,它必须被包装在 ( ) 中,即如果您不使用它们,那么它将被视为字符串. eval as a string defining function
标题看起来很蠢,但我不知道如何准确表达,抱歉。 我有一个程序需要评估一些用户代码(通过 RestrictedPython 以确保安全),并且我想将一个函数放入评估的全局变量中,以便它可以在评估时向我打
以下需要在函数范围内,因为在交互式控制台模式下不会发生奇怪的行为。 以下函数按预期返回 5 (function() { var x = 5; return eval("x"); })() 一个简单透明
我是一名优秀的程序员,十分优秀!