如何以编程方式获取页面上的angular2版本和渲染?如何以编程方式显示angular2/typescript的版本
我试图从'@ angular/core'导入{Component,Version};并试图获得该版本,但没有奏效。
如何以编程方式获取页面上的angular2版本和渲染?如何以编程方式显示angular2/typescript的版本
我试图从'@ angular/core'导入{Component,Version};并试图获得该版本,但没有奏效。
console.log(Version.major);
console.log(Version.minor);
这应该给您正在使用
不导入“版本”的主要和次要版本。进口VERSION(大写)。例如:
版本example.component.ts:
import { Component, VERSION } from "@angular/core";
@Component({
templateUrl : "./version-example.component.html"
})
export class VersionExample {
//Example 1:
theMajorVersion = VERSION.major;
//Example 2:
theMajorAndMinorVersion = `${VERSION.major}.${VERSION.minor}`; //Use backticks
//Example 3:
theFullVersion = VERSION.full;
}
版本example.component.html:
Major version: {{theMajorVersion}}
<hr/>
Major.Minor version: {{theMajorAndMinorVersion}}
<hr/>
Full version: {{theFullVersion}}
输出例如:
主要版本:5
Major.Min或版本:5.2
完整版本:5.2.0