1
typescript가 새로 도입되었습니다. 나는이 문제가 타이프 크립트와 관련이 있다고 생각한다. 이온 성 앱을 만들고 있습니다. home.html에서 setwall() 함수를 호출합니다. 나는 home.ts에서 setwall() 함수를 정의했다. 이온 앱을 실행할 때Typescript TypeError : 정의되지 않은 속성을 읽을 수 없습니다.
Runtime Error
Uncaught (in promise): TypeError: Cannot read property 'wallpaper' of undefined TypeError: Cannot read property 'wallpaper' of undefined"
이것은 내 코드 home.ts입니다. 또한 추가 정보를
import { Component } from '@angular/core';
import { NavController,Platform } from 'ionic-angular';
import { ListPage } from '../list/list';
declare var window: any;
@Component({
selector: 'page-home',
templateUrl: 'home.html'
})
export class HomePage {
constructor(public navCtrl: NavController,private platform: Platform) {
}
goPage1(){
this.navCtrl.push(ListPage);
}
setwall(){
this.platform.ready().then(() => {
window['plugins'].wallpaper.setImage("assets/img/3.jpg");
});
}
}
: https://github.com/fbsanches/cordova-plugin-wallpaper 감사 : 여기 home.html을 코드에게 코르도바 플러그인에
<ion-header>
<ion-navbar>
<button ion-button menuToggle>
<ion-icon name="menu"></ion-icon>
</button>
<ion-title>Wallfeed</ion-title>
</ion-navbar>
</ion-header>
<ion-content class="card-background-page">
<ion-card (click)="goPage1()">
<img src="assets/img/1.png"/>
<div class="card-title">São Paulo</div>
<div class="card-subtitle">41 Listings</div>
</ion-card>
<ion-card>
<img src="assets/img/2.jpg"/>
<div class="card-title">Amsterdam</div>
<div class="card-subtitle">64 Listings</div>
</ion-card>
<ion-card (click)="setwall()">
<img src="assets/img/3.jpg"/>
<div class="card-title">San Francisco</div>
<div class="card-subtitle">72 Listings</div>
</ion-card>
<ion-card>
<img src="https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQ16sUl5EqIDeuP1AjIX6ESSbAFAcS2-JLr4znf-extlfIr47Ni"/>
<div class="card-title">Madison</div>
<div class="card-subtitle">28 Listings</div>
</ion-card>
</ion-content>
링크입니다.
'window.plugins'는' – evolutionxbox
undefined'이 말을 너무 멀리 그것을 복용 할 것입니다 : 누군가가 메달이^사람에게 – Dellirium
@Dellirium ¯을 제공 \\ _ (ツ) _/¯ – evolutionxbox