Web Demo Mobile Demo Angular Demo Vue Demo React Demo
源代码
<template>
  <div>
		<h2>DataList Pagination</h2>
		<DataList style="width:550px;height:250px"
				:data="data"
				:total="total"
				:pagination="true"
				:pageNumber="pageNumber"
				:pageSize="pageSize"
				selectionMode="single"
        @selectionChange="selection=$event">
			<template slot-scope="scope">
				<div class="product">
					<div class="num">{{scope.rowIndex+1}}</div>
					<div class="detail">
						<p>{{scope.row.inv}} - {{scope.row.name}}</p>
						<p>Amount: {{scope.row.amount}}</p>
						<p>Price: {{scope.row.price}}</p>
					</div>
				</div>
			</template>
		</DataList>
    <p v-if="selection">You selected: {{selection.name}}</p>
  </div>
</template>

<script>
export default {
  data() {
    return {
      total: 0,
      pageNumber: 1,
      pageSize: 20,
      data: [],
      selection: null
    };
  },
  created() {
    let result = this.getData();
    this.total = result.total;
    this.data = result.rows;
  },
  methods: {
    getData() {
      let total = 1000;
      let data = [];
      for (let i = 1; i <= total; i++) {
        let amount = Math.floor(Math.random() * 1000);
        let price = Math.floor(Math.random() * 1000);
        data.push({
          inv: "Inv No " + i,
          name: "Name " + i,
          amount: amount,
          price: price,
          cost: amount * price,
          note: "Note " + i
        });
      }
      return {
        total: total,
        rows: data
      };
    }
  }
};
</script>
<style>
.product {
  display: flex;
  align-items: center;
  padding: 5px 0;
  border-bottom: 1px solid #eee;
}
.product .num {
  width: 40px;
  height: 40px;
  background: #b8eecf;
  border-radius: 20px;
  text-align: center;
  line-height: 40px;
  margin: 0 10px;
}
.product img {
  height: 100px;
  padding: 10px;
}
.product p {
  margin: 0;
  padding: 2px 0;
}
</style>