Nativescript Angular错误NG8001:“ StackLayout”不是已知元素:

时间:2020-10-13 01:30:53

标签: angular nativescript

src / app / components / dashboard / dashboard.component.html:1:1中的

ERROR-错误NG8001:'StackLayout'为 有一个已知元素:

  1. 如果“ StackLayout”是Angular组件,请验证它是否属于此模块。
  2. 要允许任何元素,请在此组件的“ @ NgModule.schemas”中添加“ NO_ERRORS_SCHEMA”。

1

dashboard.component.tns.html

<StackLayout>
  <Label text="dashboard works" textWrap="true"></Label>
  <Label text="This is a migrated component" textWrap="true"></Label>
  <Label text="Update it to provide the UI elements required in your mobile app" textWrap="true"></Label>
</StackLayout>

package.json

{
  "name": "angular-google-identity",
  "version": "0.0.0",
  "scripts": {
    "android": "ns run android --no-hmr",
    "ios": "ns run ios --no-hmr",
    "mobile": "ns run",
    "ng": "ng",
    "start": "ng serve",
    "build": "ng build",
    "test": "ng test",
    "lint": "ng lint",
    "eslint": "eslint 'src/**/*.ts'",
    "e2e": "ng e2e"
  },
  "private": true,
  "dependencies": {
    "@angular/animations": "^10.1.5",
    "@angular/common": "~10.0.9",
    "@angular/compiler": "~10.0.9",
    "@angular/core": "~10.0.9",
    "@angular/forms": "~10.0.9",
    "@angular/localize": "~10.0.9",
    "@angular/platform-browser": "~10.0.9",
    "@angular/platform-browser-dynamic": "~10.0.9",
    "@angular/router": "~10.0.9",
    "@angular/service-worker": "~10.0.9",
    "@nativescript/angular": "~10.1.0",
    "@nativescript/core": "~7.0.0",
    "@nativescript/theme": "~2.5.0",
    "@ng-bootstrap/ng-bootstrap": "^7.0.0",
    "@stomp/ng2-stompjs": "^7.2.0",
    "@types/node-rsa": "^1.0.0",
    "@types/socket.io-client": "^1.4.33",
    "aes-js": "^3.1.2",
    "angularx-social-login": "^3.2.1",
    "bootstrap": "^4.5.0",
    "constants": "0.0.2",
    "core-js": "^3.6.5",
    "crypto": "^1.0.1",
    "event-source-polyfill": "^1.0.16",
    "idb": "^5.0.4",
    "mediasoup-client": "^3.6.12",
    "moment": "^2.27.0",
    "nativescript-secure-storage": "^2.6.2",
    "ng-gapi": "0.0.93",
    "ngx-avatar": "^4.0.0",
    "ngx-contextmenu": "^5.4.0",
    "ngx-infinite-scroll": "^9.0.0",
    "ngx-link-preview": "^1.1.6",
    "ngx-logger": "^4.1.9",
    "ngx-webcam": "^0.3.0",
    "node-rsa": "^1.1.1",
    "primeng": "^10.0.0-rc.3",
    "recordrtc": "^5.6.1",
    "reflect-metadata": "~0.1.12",
    "rxjs": "~6.6.2",
    "rxjs-compat": "^6.6.3",
    "secure-ls": "^1.2.6",
    "socket.io": "^2.3.0",
    "socket.io-client": "^2.3.0",
    "stompjs": "^2.3.3",
    "tslib": "^2.0.1",
    "webrtc-adapter": "^7.7.0",
    "zone.js": "~0.10.3"
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "~0.1000.6",
    "@angular/cli": "~10.0.6",
    "@angular/compiler-cli": "~10.0.9",
    "@angular/language-service": "~10.0.9",
    "@nativescript/android": "7.0.0",
    "@nativescript/schematics": "^10.1.0",
    "@nativescript/tslint-rules": "~0.0.5",
    "@nativescript/webpack": "~3.0.0",
    "@types/jasmine": "~3.5.12",
    "@types/jasminewd2": "~2.0.3",
    "@types/node": "^14.6.0",
    "@typescript-eslint/eslint-plugin": "^4.1.0",
    "@typescript-eslint/eslint-plugin-tslint": "^3.9.1",
    "@typescript-eslint/parser": "^4.1.0",
    "codelyzer": "~6.0.0",
    "eslint": "^7.8.1",
    "eslint-config-google": "^0.14.0",
    "jasmine-core": "~3.6.0",
    "jasmine-spec-reporter": "~5.0.2",
    "karma": "~5.1.1",
    "karma-chrome-launcher": "~3.1.0",
    "karma-coverage-istanbul-reporter": "~3.0.3",
    "karma-jasmine": "~4.0.1",
    "karma-jasmine-html-reporter": "^1.5.4",
    "protractor": "^7.0.0",
    "ts-node": "~8.10.2",
    "tslint": "~6.1.3",
    "typescript": "~3.9.7"
  },
  "main": "main.tns.js"
}

app.module.tns.ts还具有方案:[NO_ERRORS_SCHEMA]

运行 tns build android --bundle

时遇到错误

2 个答案:

答案 0 :(得分:0)

刚刚意识到app.module.tns.ts没有声明解决此问题的仪表板组件。

@NgModule({
  declarations: [
    AppComponent,
    AutoGeneratedComponent,
    DashboardComponent
  ],

答案 1 :(得分:0)

目前的快速解决方案:使用模块声明组件并包含 schemas:[NO_ERRORS_SCHEMA]

像这样:\TestComponent - 测试组件.html - 测试组件.ts - TestComponent.module.ts <= 这应该有 schemas:[NO_ERRORS_SCHEMA]