我在 LWC superbadge 的第 14 步并收到以下错误:我们找不到在组件similarBoats JavaScript 文件中正确使用数据属性的有线服务配置函数similarBoats()。确保组件是根据要求创建的,包括relatedBoats、boatId 和similarBy 的正确值,使用正确的区分大小写和一致的引用。下面是我的文件的 JS 代码。有人可以告诉我我的代码有什么问题吗?我已经坚持这个超过24小时了。
import { LightningElement, api, wire } from 'lwc';
import getSimilarBoats from '@salesforce/apex/BoatDataService.getSimilarBoats';
import { NavigationMixin } from 'lightning/navigation'
export default class SimilarBoats extends NavigationMixin(LightningElement) {
@api similarBy;
relatedBoats;
boatId;
error;
// public
@api
get recordId() {
return this.boatId;
}
set recordId(value) {
// sets the boatId value
this.boatId = value;
// sets the boatId attribute
}
@wire(getSimilarBoats, { boatId: this.boatId, similarBy: '$similarBy' })
similarBoats({ error, data }) {
if (data) {
this.relatedBoats = data;
this.error = undefined;
} else if (error) {
this.relatedBoats = undefined;
this.error = error;
}
}
get getTitle() {
return 'Similar boats by ' + this.similarBy;
}
get noBoats() {
return !(this.relatedBoats && this.relatedBoats.length > 0);
}
// Navigate to record page
openBoatDetailPage(event) {
this[NavigationMixin.Navigate]({
type: 'standard__recordPage',
attributes: {
recordId: this.boatId,
objectApiName: BOAT_OBJECT,
actionName: 'view'
},
});
}
}