vue自定义组件 简单_一个简单且可自定义的时间表Vue组件

本文介绍如何创建一个基于Vue的简单且可定制的时间线组件,利用bootstrap、vue-fontawesome和fecha进行日期格式化。提供了安装步骤、样式设置以及Vue类组件的示例。
摘要由CSDN通过智能技术生成

vue自定义组件 简单

简单的时间线 (simple-vue-timeline)

A timeline vue component which leverages the use of common libraries:

时间轴Vue组件,利用了公共库的使用:

  • bootstrap vue components,

    引导vue组件,

  • vue-fontawesome

    Vue-fontawesome

  • and fecha date formatting.

    和fecha日期格式。

入门 (Getting Started)

安装 (Installation)

npm install --save simple-vue-timeline

样式 (Style)

@import '~simple-vue-timeline/dist/simple-vue-timeline';

As bootstrap is used, you must add the bootstrap style:

使用引导程序时,必须添加引导程序样式:

@import '~bootstrap/scss/bootstrap';

字体很棒 (Font Awesome)

Refer to vue-fontawesome documentation.

请参阅vue-fontawesome文档。

模板元素 (Template Element)

Add the element as follow:

如下添加元素:

template

template

<timeline :items="items" dateFormat="YY/MM/DD" @timeline-edit="edit" v-on="$listeners"></timeline>

script

script

import { SimpleTimeline, Item, Control, Status } from 'simple-vue-timeline';

@Component({
  components: {
    timeline: SimpleTimeline
  }
})
export default class ...

Refer to the Vue Class Component Sample section below for a complete sample.

有关完整的示例,请参考下面的Vue Class Component Sample部分。

Vue类组件样本 (Vue Class Component Sample)

<template>
  <div id="app">
    <timeline
      :items="items"
      @timeline-edit="edit"
      @timeline-copy="copy"
      @timeline-trash="trash"
      v-on="$listeners"
    ></timeline>
  </div>
</template>

<script lang="ts">
import { Component, Vue } from "vue-property-decorator";
import {
  SimpleTimeline,
  Item,
  Control,
  Status
} from "simple-vue-timeline";

@Component({
  components: {
    timeline: SimpleTimeline
  }
})
export default class App extends Vue {
  public items: Item[] = [
    new Item(
      0,
      "calendar-alt",
      Status.WARNING,
      "title",
      [new Control("edit", "pencil-alt"), new Control("copy", "plus")],
      new Date(),
      "Here is the body message of item 0"
    ),
    new Item(
      1,
      "tasks",
      Status.WARNING,
      "title",
      [new Control("edit", "pencil-alt"), new Control("trash", "trash")],
      new Date(2019, 10, 20),
      "Here is the body message of item 1"
    )
  ];

  public edit(e: any) {
    console.log("edit " + e["eventId"]);
  }

  public copy(e: any) {
    console.log("copy " + e["eventId"]);
  }

  public trash(e: any) {
    console.log("trash " + e["eventId"]);
  }
}
</script>

翻译自: https://vuejsexamples.com/a-simple-and-customizable-timeline-vue-component/

vue自定义组件 简单

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值