vue.js水平时间轴_用Vue.js制作的简单水平时间轴组件
vue.js水平时间轴 Vue水平时间线 (Vue Horizontal Timeline)a simple horizontal timeline component made with Vue.js.一个由Vue.js制作的简单水平时间轴组件。View Demo查看演示 View Github查看Github如何安装 (How to install)npm (npm)...
vue.js水平时间轴
Vue水平时间线 (Vue Horizontal Timeline)
a simple horizontal timeline component made with Vue.js.
一个由Vue.js制作的简单水平时间轴组件。
如何安装 (How to install)
npm (npm)
$ npm install vue-horizontal-timeline --save
纱线(推荐) (yarn (recommended))
$ yarn add vue-horizontal-timeline
快速开始 (Quick start)
Vue.js (Vue.js)
You can import in your main.js file
您可以导入main.js文件
import Vue from "vue";
import VueHorizontalTimeline from "vue-horizontal-timeline";
Vue.use(VueHorizontalTimeline);
Or locally in any component
或本地任何组件
import { VueHorizontalTimeline } from "vue-horizontal-timeline";
export default {
components: {
VueHorizontalTimeline
}
};
Nuxt.js (Nuxt.js)
You can import as a Nuxt.js plugin
您可以导入为Nuxt.js插件
~/plugins/vue-horizontal-timeline.js
~/plugins/vue-horizontal-timeline.js
import Vue from "vue";
import VueHorizontalTimeline from "vue-horizontal-timeline";
Vue.use(VueHorizontalTimeline);
and then import it in your nuxt.config.js file
然后将其导入到您的nuxt.config.js文件中
plugins: ["~/plugins/vue-horizontal-timeline.js"];
基本用法 (Basic usage)
<template>
<vue-horizontal-timeline :items="items" />
</template>
<script>
export default {
data() {
const example1 = {
title: "Title example 1",
content:
"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ex dolor, malesuada luctus scelerisque ac, auctor vitae risus. Vivamus risus dolor, faucibus a bibendum quis, facilisis eget odio."
};
const example2 = {
title: "Title example 2",
content:
"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ex dolor, malesuada luctus scelerisque ac, auctor vitae risus. Vivamus risus dolor, faucibus a bibendum quis, facilisis eget odio."
};
const example3 = {
title: "Title example 3",
content:
"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ex dolor, malesuada luctus scelerisque ac, auctor vitae risus. Vivamus risus dolor, faucibus a bibendum quis, facilisis eget odio."
};
const items = [example1, example2, example3];
return { items };
}
};
</script>
道具 (Props)
| Property name | Type | Default | Description |
|---|---|---|---|
| items | Array | null | Array of objects to be displayed. Must have at least a content property |
| item-selected | Object | {} | Object that is set when it is clicked. Note that clickable prop must be set to true |
| item-unique-key | String | '' | Key to set a blue border to the card when it is clicked (clickable prop must be set to true) |
| title-attr | String | 'title' | Name of the property inside the objects, that are in the items array, to set the cards title |
| title-centered | Boolean | false | Centralizes the cards title |
| title-class | String | '' | If you want to set a custom class to the cards title, set it here |
| title-substr | String | 18 | Number of characters to display inside the cards title. Above this, will set a '...' mask |
| content-attr | String | 'content' | Name of the property inside the objects, that are in the items array, to set the cards content |
| content-centered | Boolean | false | Centralizes all the cards content text |
| content-class | String | '' | If you want to set a custom class to the cards content, set it here |
| content-substr | String | 250 | Number of characters to display inside the cards content. Above this, will set a '...' mask |
| min-width | String | '200px' | Min-width of the timeline |
| min-height | String | '' | Min-height of the timeline |
| timeline-padding | String | '' | Padding of the timeline |
| timeline-background | String | '#E9E9E9' | Background color of the whole timeline |
| line-color | String | '#03A9F4' | Color of the line inside the timeline |
| clickable | Boolean | true | Makes the card clickable that returns the object |
| 物业名称 | 类型 | 默认 | 描述 |
|---|---|---|---|
| 项目 | 数组 | 空值 | 要显示的对象数组。 必须至少具有一个内容属性 |
| 项目选择 | 目的 | {} | 单击时设置的对象。 请注意, clickable道具必须设置为true |
| 项唯一键 | 串 | '' | 单击时在卡片上设置蓝色边框的键(必须将clickable道具设置为true) |
| 标题属性 | 串 | '标题' | 位于项目数组中的对象内部的属性的名称,用于设置卡片标题 |
| 以标题为中心 | 布尔型 | 假 | 集中卡片标题 |
| 头等舱 | 串 | '' | 如果要为卡片标题设置自定义类别,请在此处进行设置 |
| 标题替换 | 串 | 18 | 卡片标题中显示的字符数。 在此之上,将设置一个“ ...”遮罩 |
| 内容征询 | 串 | '内容' | 位于项目数组中的对象内部的属性名称,用于设置卡片内容 |
| 以内容为中心 | 布尔型 | 假 | 集中所有卡片内容文本 |
| 内容类别 | 串 | '' | 如果要为卡片内容设置自定义类别,请在此处进行设置 |
| 内容替代 | 串 | 250 | 卡内容中要显示的字符数。 在此之上,将设置一个“ ...”遮罩 |
| 最小宽度 | 串 | '200px' | 时间线的最小宽度 |
| 最小高度 | 串 | '' | 时间轴的最小高度 |
| 时间线填充 | 串 | '' | 时间轴的填充 |
| 时间轴背景 | 串 | '#E9E9E9' | 整个时间轴的背景色 |
| 线色 | 串 | '#03A9F4' | 时间轴内线的颜色 |
| 可点击的 | 布尔型 | 真正 | 使卡片可点击以返回对象 |
发展历程 (Development)
Fork the project and enter this commands in your terminal
分叉项目并在终端中输入此命令
git clone https://github.com/YOUR_GITHUB_USERNAME/vue-horizontal-timeline.git
cd vue-horizontal-timeline
yarn
故事书 (Storybook)
For visual testing, this project contains storybook which you can run by doing the next command
对于视觉测试,该项目包含故事书,您可以通过执行以下命令来运行它
$ yarn storybook:serve
笑话 (Jest)
Before making the PR, if you changed something that needs to be tested, please make the tests inside the tests/unit folder.
在制作PR之前,如果您更改了需要测试的内容,请在tests/unit文件夹中tests/unit 。
To run the tests, you can use the next command
要运行测试,可以使用下一个命令
$ yarn test:unit
承诺 (Commitlint)
This project follows the commitlint guidelines, with minor changes.
该项目遵循commitlint准则,但进行了一些小的更改。
You can commit using npm run commit to help you with that.
您可以使用npm run commit来npm run commit帮助。
There's a pre-push hook that runs all the unit tests before you can push it.
有一个pre-push钩子可以运行所有单元测试,然后再将其推入。
If an error occurs, you can use the npm run commit:retry command that runs the previous npm run commit that you already filled.
如果发生错误,则可以使用npm run commit:retry命令来运行您先前已填写的npm run commit 。
去做 (TODO)
-
[x] Add 100% test coverage
[x]增加100%的测试覆盖率
-
[x] Add demo website/code pen
[x]添加演示网站/代码笔
-
[x] Publish in npm
[x]在npm中发布
翻译自: https://vuejsexamples.com/a-simple-horizontal-timeline-component-made-with-vue-js/
vue.js水平时间轴
魔乐社区(Modelers.cn) 是一个中立、公益的人工智能社区,提供人工智能工具、模型、数据的托管、展示与应用协同服务,为人工智能开发及爱好者搭建开放的学习交流平台。社区通过理事会方式运作,由全产业链共同建设、共同运营、共同享有,推动国产AI生态繁荣发展。
更多推荐


所有评论(0)