我正在使用一个包用于我的布局,我需要在页面上加载所有元素之后调用javascript,但我无法让它工作。
ionViewDidEnter() {
this.graphs = [];
// console.log("View Entering", this.iter);
this.setCurrentPosition();
this.clientService.clientStream$.subscribe(
client => {
this.client = client;
this.isLoading = false;
this.setupGrid();
}
)
}
setupGrid() {
var elem = document.querySelector('.pckry-grid');
// Prints "setting up grid, null"
console.log("setting up grid", elem)
var pckry = new Packery( elem, {
itemSelector: ".grid-item"
});
}
以下是观点:
<div class="pckry-grid" *ngIf="!isLoading">
<div class="grid-item g-col-12">
...
</div>
<div class="grid-item g-col-12">
...
</div>
<div class="grid-item g-col-12">
...
</div>
<div class="grid-item g-col-12">
...
</div>
</div>
我可以使用不同的钩子阻止setupGrid()
函数在元素加载之前调用吗?