我想在角度独立组件 v14 中使用ngx-avatar 。
我在模板中使用它,并在组件导入中导入它。
但我收到错误消息:
Component imports must be standalone components, directives, pipes, or must be NgModules.
Run Code Online (Sandbox Code Playgroud)
import { AvatarModule } from 'ngx-avatar';
@Component({
selector: 'my-app',
standalone: true,
imports: [AvatarModule, CommonModule],
template: `
app works!
<ngx-avatar class="my-avatar" value="HM"> </ngx-avatar>
`,
})
export class AppComponent {
name = 'Angular ' + VERSION.major;
}
Run Code Online (Sandbox Code Playgroud)
我尝试使用它来解决它,importProvidersFrom但它不起作用:
bootstrapApplication(
AppComponent, {
providers: [importProvidersFrom(AvatarModule.forRoot())],
}
);
Run Code Online (Sandbox Code Playgroud)
知道我怎样才能让它发挥作用吗?
问题: 我创建了一个带有自定义工具提示的条形图。现在我需要的是将工具提示放置在栏的顶部而不是图表区域内。就像这张照片一样。
这就是现在的样子。
在这里我提供了我如何组织我的代码。
import React, { Component } from "react";
import {
BarChart,
Tooltip,
Bar,
Legend,
ResponsiveContainer,
Cell
} from "recharts";
import { Card, CardTitle, CardBody } from "reactstrap";
import "./SessionDuration.css";
const colors = ["#26a0a7", "#79d69f", "#f9ec86", "#ec983d"];
const data = [
{
name: "Page A",
pv: 2400,
amt: 2400
},
{
name: "Page B",
pv: 1398,
amt: 2210
},
{
name: "Page C",
pv: 9800,
amt: 2290
},
{
name: "Page D",
pv: 3908,
amt: 2000
}
]; …Run Code Online (Sandbox Code Playgroud) 我有一个 Angular 项目,我试图在其中使用 Angular 材质库。在我的app-routing.module我有这样的代码:
import { NgModule } from '@angular/core';
import { RouterModule, Routes } from '@angular/router';
import { SndComingSoonPageComponent } from './feature/pages/snd-coming-soon-page/snd-coming-soon-page.component';
const routes: Routes = [
{ path: '', pathMatch: 'full', component: SndComingSoonPageComponent },
];
@NgModule({
imports: [RouterModule.forRoot(routes)],
exports: [RouterModule],
})
export class AppRoutingModule {}
Run Code Online (Sandbox Code Playgroud)
我正在SndComingSoonPageComponent尝试使用MatIconModule,但无论我在哪里导入它,我仍然无法使用它。
这是我的app.module.ts:
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { AppRoutingModule } from './app-routing.module';
import { AppComponent } …Run Code Online (Sandbox Code Playgroud) 几天来我遇到了某个错误:未捕获错误:JIT 编译器不可用。将 Angular 从版本 8 升级到 12 后出现了一个问题,我运行 ng build --prod --output-path = dist 命令并构建 Angular 我没有问题,但是当我启动页面时,会弹出这个 JIT 问题。我已经尝试了堆栈溢出中的所有解决方案,就像我在 package.json 中添加的那样
scripts{
"postinstall": "ngcc --properties es5 browser module main --first-only"
}Run Code Online (Sandbox Code Playgroud)
我在 main.ts '@angular/compiler' 中添加 在“angularCompilerOptions”中的 tsconfig.json 中,我将“enableIvy”更改为 true 一篇文章说更改为 true,另一篇文章说更改为 false,但这些解决方案都不适合我。我重新安装了node_modules几次并添加了几个依赖项,但没有任何效果。这是我的 tsconfig 文件:
{
"compileOnSave": false,
"compilerOptions": {
"baseUrl": "./",
"outDir": "./dist/out-tsc",
"sourceMap": true,
"declaration": false,
"downlevelIteration": true,
"experimentalDecorators": true,
"module": "es2020",
"moduleResolution": "node",
"importHelpers": true,
"resolveJsonModule": true,
"target": "es5",
"skipLibCheck": true,
"typeRoots": [
"node_modules/@types"
],
"lib": [
"es2015", …Run Code Online (Sandbox Code Playgroud)