
[英]Can't use angular2-materialize (TypeError: jQuery.easing is undefined)
[英]Trying to use angular2-materialize and can't seem to solve loading problems
我整天都在打字上工作,以便在没有太多运气的情况下使用angular2-materialize和materialize-css。
我安装了npm install和save选项。
这是我遇到的错误之一:
(索引):29错误:语法错误:意外的令牌<(…)
这行是:
<script src="systemjs.config.js"></script>
有什么建议吗?
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',
// other libraries
'rxjs': 'npm:rxjs',
'angular2-in-memory-web-api': 'npm:angular2-in-memory-web-api',
"materialize-css": "node-modules/materialize-css",
"angular2-materialize": "node_modules/angular2-materialize"
},
// packages tells the System loader how to load when no filename and/or no extension
packages: {
app: {
main: './main.js',
defaultExtension: 'js'
},
rxjs: {
defaultExtension: 'js'
},
'materialize-css': {
"format": "global",
"main": "dist/js/materialize",
"defaultExtension": "js"
},
'angular2-materialize': {
"main": "dist/index",
"defaultExtension": "js"
}
}
});
})(this);
app.component.ts
import { Component } from '@angular/core';
import 'node_modules/materialize-css';
import 'node_modules/angular2-materialize';
@Component({
selector: 'shows-app',
templateUrl: 'app/app.component.html',
styleUrls: ['app/material.min.css']
})
export class AppComponent {
pageTitle: string = 'NetShows';
showMenu: boolean = true;
public loggedIn: boolean = false;
public menuButtonClick() {
this.showMenu = !this.showMenu;
}
}
index.html
<!DOCTYPE html>
<html style="html, body {height:100;padding:0;margin:0}">
<head lang="en">
<base href=".">
<title>NetShows Horse Show Management</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="app/app.component.css" rel="stylesheet" />
<link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons">
<!--<link rel="stylesheet" href="node_modules/material-design-lite/dist/material.light_blue-amber.min.css" />-->
<link rel="stylesheet" href="https://code.getmdl.io/1.2.1/material.indigo-pink.min.css">
<!-- Material Design icon font -->
<link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons">
<script defer src="node_modules/material-design-lite/dist/material.min.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/reflect-metadata/Reflect.js"></script>
<script src="node_modules/systemjs/dist/system.src.js"></script>
<script src="https://code.getmdl.io/1.2.1/material.min.js"></script>
<!-- Configure SystemJS -->
<script src="systemjs.config.js"></script>
<script>
System.import('app').catch(function(err){ console.error(err); });
</script>
</head>
<body>
<shows-app>Loading App...</shows-app>
</body>
</html>
解:
我错了两件事
我将导入更改为:
import 'materialize-css';
import 'angular2-materialize';
生活是美好的。 我以为我对systemjs.config.js文件做错了,但是事实并非如此。
我确实在以下位置找到了有关systemjs的精彩文章:
https://superdevelopment.com/2016/03/16/a-dive-into-systemjs-part-1/
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.