简体   繁体   English

模块解析失败:您可能需要适当的加载程序来处理此文件类型

[英]Module parse failed:You may need an appropriate loader to handle this file type

Please forgive me if the question is very simple. 如果问题很简单,请原谅我。 I have just started learning Angular. 我刚刚开始学习Angular。 I am trying my first app. 我正在尝试我的第一个应用程序。 But it does not compile. 但是它不能编译。 Because it does not recognize part of my code. 因为它无法识别我的代码的一部分。 I was wondering if somebody can give me some hints on what I am doing wrong in here? 我想知道是否有人可以给我一些暗示我在这里做错了什么?

app.component.html file: app.component.html文件:

<!--The whole content below can be removed with the new code.-->
<div style="text-align:center">
  <h1>
    Welcome to {{pageTitle}}!!
  </h1>
  ... Starter Files ...
</div>

app.component.ts file app.component.ts文件

import { Component } from '@angular/core';

@Component({
  selector: 'pm-root',
  template: <div><h1>{{pageTitle}}</h1></div> // **this line of code created error**  
})
export class AppComponent {
  pageTitle: string = 'Angular: Getting Started';
}

app.module.ts app.module.ts

import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { AppComponent } from './app.component';

@NgModule({
  declarations: [
    AppComponent
  ],
  imports: [
    BrowserModule
  ],
  providers: [],
  bootstrap: [AppComponent]
})
export class AppModule { }

index.html 的index.html

<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <title>Acme Product Management</title>
  <base href="/">

  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="icon" type="image/x-icon" href="favicon.ico">
</head>
<body>
  <pm-root></pm-root>
</body>
</html>

here is the error : 这是错误: 在此处输入图片说明 would you please give some help on how to fix this ? 您能提供一些解决方法的帮助吗?

You don't have backticks or quotes in your template: 您的模板中没有反引号或引号:

The template is a multi-line string within ECMAScript 2015 backticks ( ). The backtick ( 模板是ECMAScript 2015反引号( ). The backtick (的多行字符串). The backtick ( ). The backtick ( )—which is not the same character as a single quote (')—allows you to compose a string over several lines, which makes the HTML more readable. ). The backtick ( )与单引号(')不同,它使您可以在多行上组成一个字符串,从而使HTML更具可读性。

import { Component } from '@angular/core';

    @Component({
      selector: 'pm-root',
      template: `<div><h1>{{pageTitle}}</h1></div>` // **added backticks**  
    })
    export class AppComponent {
      pageTitle: string = 'Angular: Getting Started';
    }

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 模块分析失败:括号模式您可能需要适当的加载程序来处理此文件类型 - Module parse failed: Parenthesized pattern You may need an appropriate loader to handle this file type Angular 2 - Karma 错误 - 模块解析失败“您可能需要合适的加载程序来处理此文件类型” - Angular 2 - Karma Error - Module Parse Failed 'You may need an appropriate loader to handle this file type' 未捕获的错误:模块解析失败:您可能需要合适的加载程序来处理此文件类型 - Uncaught Error: Module parse failed:You may need an appropriate loader to handle this file type 未捕获(承诺):错误:模块解析失败:意外令牌(91:0)您可能需要适当的加载程序来处理此文件类型 - Uncaught (in promise): Error: Module parse failed: Unexpected token (91:0) You may need an appropriate loader to handle this file type 您可能需要适当的加载器来处理此文件类型-带有React的Angular 4 - You may need an appropriate loader to handle this file type - Angular 4 with React 您可能需要适当的加载程序来处理此文件-.net core和Angular - You may need an appropriate loader to handle this file - .net core & Angular “你可能需要一个适合这种文件类型的加载器”,webpack 无法解析 angular2 文件 - “You may need an appropriate loader for this file type”, webpack can't parse angular2 file 您可能需要适当的加载程序来处理此文件类型。 Angular 5应用程序中的错误 - You may need an appropriate loader to handle this file type. error in Angular 5 app 使用 Angular 和 LitElement 时,您可能需要适当的加载程序来处理此文件类型 - You may need an appropriate loader to handle this file type when using Angular and LitElement index.ngfactory.ts意外的令牌,您可能需要适当的加载程序来处理此文件类型 - index.ngfactory.ts Unexpected token, You may need an appropriate loader to handle this file type
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM