【问题标题】:How to bind dataSource in dx Gallery?如何在 dx Gallery 中绑定数据源?
【发布时间】:2020-12-06 21:29:32
【问题描述】:

数据源需要绑定在更嵌套的循环中。

        <div *ngFor="let singleImg of training.exercise.pictureList; let t = index">
          <dx-gallery #gallery  
          id="gallery"
          [dataSource]="singleImg.url" 
          [loop]="true"
          [height]="300"
          [showNavButtons]="true"
          [showIndicator]="true"
      ></dx-gallery>
        </div>

我在 training.exercise.pictureList 之前有一个循环,但这对你来说并不重要。 我知道在 .ts 文件中循环并在此处绑定数组,但总是打印相同的照片...... 这里可能是要绑定的索引问题

【问题讨论】:

    标签: angular devextreme devextreme-angular


    【解决方案1】:

    根据 devextreme 的文档,datasource 是每个图像的 url 的字符串数组。

    例如:

    [dataSource] = [
        "images/gallery/1.jpg",
        "images/gallery/2.jpg",
        "images/gallery/3.jpg",
        "images/gallery/4.jpg",
        "images/gallery/5.jpg",
        "images/gallery/6.jpg",
        "images/gallery/7.jpg",
        "images/gallery/8.jpg",
        "images/gallery/9.jpg"];
    

    您可以尝试删除 div 元素并将数组直接提供给 dataSource 像:

    <dxGalley 
    [dataSource]= "training.exercise.pictureList";>
    

    【讨论】:

    • 朋友这不行[dataSource]="training.exercise.pictureList";>
    • 试试这个 ->picture.url)">
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-02-13
    • 2012-11-23
    • 2013-07-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多