加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

使用指令时,Angular会给出@ angular / core 404找不到错误

发布时间:2020-12-17 07:50:51 所属栏目:安全 来源:网络整理
导读:当我将这行代码添加到我的@Component中时: directives: [HeroDetailComponent] 代码中断,并给我这个错误: GET http://localhost:3000/@angular/core 404 (Not Found) 这些是我的index.html中的脚本: script src="node_modules/es6-shim/es6-shim.min.js"/
当我将这行代码添加到我的@Component中时:
directives: [HeroDetailComponent]

代码中断,并给我这个错误:

GET http://localhost:3000/@angular/core 404 (Not Found)

这些是我的index.html中的脚本:

<script src="node_modules/es6-shim/es6-shim.min.js"></script>
<script src="node_modules/systemjs/dist/system-polyfills.js"></script>
<script src="node_modules/angular2/es6/dev/src/testing/shims_for_IE.js"></script>   

<script src="node_modules/angular2/bundles/angular2-polyfills.js"></script>
<script src="node_modules/systemjs/dist/system.src.js"></script>
<script src="node_modules/rxjs/bundles/Rx.js"></script>
<script src="node_modules/angular2/bundles/angular2.dev.js"></script>

如果我错过了诊断此问题的任何信息,请告诉我,我会将其包含在此处.

如果要使用RC版本的Angular2,则需要以这种方式配置SystemJS:
var packages = {
  'app': { main: 'main.js',defaultExtension: 'js' },'rxjs': { defaultExtension: 'js' },'angular2-in-memory-web-api': { defaultExtension: 'js' },};

var packageNames = [
  '@angular/common','@angular/compiler','@angular/core',// <--------
  '@angular/http','@angular/platform-browser','@angular/platform-browser-dynamic','@angular/router','@angular/router-deprecated','@angular/testing','@angular/upgrade',];

packageNames.forEach(function(pkgName) {
  packages[pkgName] = { main: 'index.js',defaultExtension: 'js' };
});

var config = {
  map: map,packages: packages
}

System.config(config);

如果要使用beta版本,在脚本元素中包含node_modules / angular2 / bundles / angular2.dev.js文件后,请导入此包:

import {Component,Directive,...} from 'angular2/core';

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读