我正在开发应用程序。代码在控制台中运行良好,没有任何错误,但 html 中没有信息。这是代码:home.page.html
<ion-header>
<ion-toolbar>
<ion-buttons slot="start">
<ion-menu-button></ion-menu-button>
</ion-buttons>
<ion-title>
Home
</ion-title>
</ion-toolbar>
</ion-header>
<ion-content>
<ion-grid>
<ion-row>
<ion-slides>
<ion-slide *ngFor="let product of products">
<ion-card no-padding>
<img [src]= 'product.images[0].src' />
<p>{{product.name}}</p>
<p>{{product.title}}</p>
</ion-card>
</ion-slide>
</ion-slides>
</ion-row>
</ion-grid>
</ion-content>
主页.ts
import { Component } from '@angular/core';
import { NavController } from '@ionic/angular';
import * as WS from 'woocommerce-api';
@Component({
selector: 'app-home',
templateUrl: 'home.page.html',
styleUrls: ['home.page.scss'],
})
export class HomePage {
WooCommerce : any;
products : any[];
constructor(public navCtrl : NavController)
{
this.WooCommerce = WS({
url:"http://*****.com",
consumerKey: "ck_******",
consumerSecret: "cs_*****",
wpAPI: true,
version: 'wc/v1'
});
this .WooCommerce.getAsync("products").then((data) =>{
console.log(JSON.parse(data.body));
this.products= JSON.parse(data.body).products;
},(err) =>{
console.log(err)
})
}
离子信息:
离子(离子 CLI):4.10.0
系统:
NodeJS:v11.8.0 npm:6.5.0 操作系统:Windows 10