首页 > 解决方案 > 设置水平滚动位置 - Ionic 3

问题描述

我正在尝试更改ion-scroll元素的滚动位置,但没有得到..这是我尝试过的:

ts

import { Component, ViewChild, ElementRef } from "@angular/core";

 @ViewChild("scroller", { read: ElementRef })
  private scroller: ElementRef;

html

 <ion-scroll #scroller scrollX="true" style="height: 21px; white-space: nowrap">
  <div>... </div>
 </ion-scroll>

这有效

  this.scroller.nativeElement.style.background = "blue";

这不起作用

  this.scroller.nativeElement.scrollLeft = this.scroller.nativeElement.scrollWidth;

标签: angularionic-frameworkionic2ionic3

解决方案


推荐阅读