|
@@ -1,11 +1,26 @@
|
|
|
-import { Component } from '@angular/core';
|
|
|
+import { Component, Input, Output, EventEmitter } from '@angular/core';
|
|
|
+import { FontAwesomeModule } from '@fortawesome/angular-fontawesome';
|
|
|
+import { faTrashAlt } from '@fortawesome/free-solid-svg-icons';
|
|
|
|
|
|
@Component({
|
|
|
- selector: 'app-cart-item.component',
|
|
|
- imports: [],
|
|
|
+ selector: 'app-cart-item', // 修正选择器名称
|
|
|
+ standalone: true,
|
|
|
+ imports: [FontAwesomeModule], // 添加 FontAwesomeModule 导入
|
|
|
templateUrl: './cart-item.component.html',
|
|
|
- styleUrl: './cart-item.component.scss'
|
|
|
+ styleUrls: ['./cart-item.component.scss']
|
|
|
})
|
|
|
export class CartItemComponent {
|
|
|
+ @Input() item: any; // 添加 item 输入属性
|
|
|
+ @Output() quantityChange = new EventEmitter<number>();
|
|
|
+ @Output() remove = new EventEmitter<void>();
|
|
|
|
|
|
-}
|
|
|
+ faTrashAlt = faTrashAlt; // 添加图标定义
|
|
|
+
|
|
|
+ updateQuantity(change: number): void {
|
|
|
+ this.quantityChange.emit(change);
|
|
|
+ }
|
|
|
+
|
|
|
+ removeItem(): void {
|
|
|
+ this.remove.emit();
|
|
|
+ }
|
|
|
+}
|