首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >导入节点模块时XHR错误404 -角-2

导入节点模块时XHR错误404 -角-2
EN

Stack Overflow用户
提问于 2017-07-01 15:55:50
回答 1查看 155关注 0票数 0

我的目录结构如下:

代码语言:javascript
复制
dir
   |--app.component.ts

  node_modules
  |--angular2-bootstrap-switch

我遵循https://www.npmjs.com/package/angular2-bootstrap-switch添加angular2引导开关,按照指示,我不得不这样做,但是,我不知道怎么做。

index.html:

代码语言:javascript
复制
<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/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>


<!-- 2. Configure SystemJS -->
<script>
  System.config({
    packages: {        
      app: {
        format: 'register',
        defaultExtension: 'js'
      }

    }
  });


     System.import('app/boot')
            .then(null, console.error.bind(console));
    </script>

  </head>

  <!-- 3. Display the application -->
  <body>
    <my-app>Loading...</my-app>
  </body>

内部boot.ts

代码语言:javascript
复制
 import {bootstrap}    from 'angular2/platform/browser'
import {AppComponent} from './app.component'

bootstrap(AppComponent);

在tsconfig.json中

代码语言:javascript
复制
 "exclude": [
    "node_modules",
    "typings/main",
    "typings/main.d.ts"
  ]

现在我必须在../node_modules/angular2_bootstrap_switch/components中导入app.component.ts,比如:

代码语言:javascript
复制
import {SwitchComponent} from angular2_bootstrap_switch/components

我不确定是怎么回事。请帮帮忙。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2017-07-01 16:18:20

使用这个非常简单。

  1. 安装node_module npm安古拉2-自举开关
  2. 在您的系统Js中添加配置如下: 'angular2-bootstrap-switch':'npm:angular2-bootstrap-switch/lib/switch.component.js‘
  3. 在App中,将开关组件导入为 从‘angular2-引导-开关’导入{SwitchComponent}
  4. 将其添加到声明中,如下所示 声明: SwitchComponent,
  5. 在HTML中使用它作为 <开关status=“值”onText="onText“offText="offText”onColor="onColor“offColor="offColor”size="size">“

LIVE DEMO

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/44862818

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档