亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

Angular2異常:由于它不是已知的本機屬性,因此無法綁定到“ routerLink”

Angular2異常:由于它不是已知的本機屬性,因此無法綁定到“ routerLink”

鴻蒙傳說 2019-11-27 12:52:45
顯然,Angular2的beta版比新的要新,因此那里沒有太多的信息,但是我正在嘗試做一些我認為比較基本的路由。從https://angular.io網站竊取快速入門代碼和其他代碼片段導致了以下文件結構:angular-testapp/    app/        app.component.ts        boot.ts        routing-test.component.ts    index.html文件填充如下:index.html<html>  <head>    <base href="/">    <title>Angular 2 QuickStart</title>    <link href="../css/bootstrap.css" rel="stylesheet">    <!-- 1. Load libraries -->    <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>    <script src="node_modules/angular2/bundles/router.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></html>引導程序import {bootstrap}    from 'angular2/platform/browser'import {ROUTER_PROVIDERS} from 'angular2/router';import {AppComponent} from './app.component'bootstrap(AppComponent, [    ROUTER_PROVIDERS]);app.component.tsimport {Component} from 'angular2/core';import {RouteConfig, ROUTER_DIRECTIVES, ROUTER_PROVIDERS, LocationStrategy, HashLocationStrategy} from 'angular2/router';import {RoutingTestComponent} from './routing-test.component';@Component({    selector: 'my-app',    template: `        <h1>Component Router</h1>        <a [routerLink]="['RoutingTest']">Routing Test</a>        <router-outlet></router-outlet>        `})我在這里發現了一個模糊的相關問題;升級到angular2.0.0-beta.0后,router-link指令中斷。但是,答案之一中的“有效示例”是基于beta版的代碼-可能仍然可以使用,但是我想知道為什么我創建的代碼不起作用。
查看完整描述

3 回答

?
HUH函數

TA貢獻1836條經驗 獲得超4個贊

使用Visual Studio進行編碼時的警告語(2013)


我已經浪費了4至5個小時來嘗試調試此錯誤。我嘗試通過字母找到在stackoverflow上找到的所有解決方案,但仍然出現此錯誤:Can't bind to 'routerlink' since it isn't a known native property


請注意,在復制/粘貼代碼時,Visual Studio有自動格式化文本的討厭習慣。我總是從VS13得到一個小的瞬時調整(駱駝的情況消失了)。


這個:


<div>

    <a [routerLink]="['/catalog']">Catalog</a>

    <a [routerLink]="['/summary']">Summary</a>

</div>

成為:


<div>

    <a [routerlink]="['/catalog']">Catalog</a>

    <a [routerlink]="['/summary']">Summary</a>

</div>

差異很小,但足以觸發錯誤。最丑陋的部分是,每次我復制粘貼時,這種微小的差異一直在避免我的注意。碰巧的機會,我看到了這個微小的區別并解決了。


查看完整回答
反對 回復 2019-11-27
  • 3 回答
  • 0 關注
  • 803 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號