Mik*_*ike 8 angular-cli angular
组件定义如下:
import {Component} from '@angular/core';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.less']
})
export class AppComponent {
}
Run Code Online (Sandbox Code Playgroud)
我想加载一些特定的组件而不是“app.component.html”扩展名为“app.component.htm”的文件
@Component({
selector: 'app-root',
templateUrl: './app.component.htm',
styleUrls: ['./app.component.less']
})
Run Code Online (Sandbox Code Playgroud)
由于某种原因它不起作用它说:
ERROR in ./app.component.htm 1:0
Module parse failed: Unexpected token (1:0)
You may need an appropriate loader to handle this file type.
<p>
app component works!
</p>
?wdm?: Failed to compile.
Run Code Online (Sandbox Code Playgroud)
请帮我找到一种加载htm文件的方法?我知道有一种方法可以使用 Webpack 进行引导,我想保留 ng-serve\cli angular.json 的当前版本!
谢谢!
将您的 Angular 版本升级到 Angular 8,这已在 Angular 8 中修复。
@Component({
selector: 'app-root',
templateUrl: './app.component.htm',
styleUrls: ['./app.component.less']
})
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1851 次 |
| 最近记录: |