我正在使用 'firebase' 而不是 '@angular/fire' 并收到一條錯誤訊息No suitable injection token for parameter 'functions' of class 'TodosComponent'。
用todos.component.ts撰寫的代碼
import { Component, OnDestroy, OnInit } from '@angular/core';
import { TodosService } from '../todos.service';
import { Todo } from './Todo';
import * as functions from 'firebase/functions';
declare var StripeCheckout: StripeCheckoutStatic;
@Component({
selector: 'app-todos',
templateUrl: './todos.component.html',
styleUrls: ['./todos.component.scss']
})
export class TodosComponent implements OnInit, OnDestroy {
todos!: Todo[];
localItem: string | null;
completedTodos: number = 0;
date: string = new Date().toUTCString();
constructor(private functions: functions.Functions) {
..........
}
......
}
我在private functions: functions.Functions.
uj5u.com熱心網友回復:
當您直接從“firebase/functions”匯入時,您不需要注入建構式。
您可以直接使用這些功能。
private functions: functions.Functions從建構式中移除。
直接使用函式。無需使用this.functions
例如,
functions.firestore.document('/messages/{documentId}')
轉載請註明出處,本文鏈接:https://www.uj5u.com/yidong/445935.html
