vue-ruler-tool
最近在网上找到一个 网页制做辅助工具-jQuery标尺参考线插件 ,以为在如今的一个项目中能用的上,插件是基于JQuery的,可是如今的项目是用vue写的。So...,
就照葫芦画瓢改装成了Vue组件,总的来讲算是一个用处较多的组件,因而乎,就想着把它分享出来。
项目地址
https://github.com/gorkys/vue...vue
特色
- 没有依赖
- 可拖动的辅助线
- 快捷键支持
好吧,其实这个组件没什么太多的特色~
安装与基本用法
$ npm install --save vue-ruler-tool
全局注册git
import Vue from 'vue' import VueRulerTool from 'vue-ruler-tool' Vue.component('vue-ruler-tool', VueRulerTool)
你如今就能够使用该组件了github
<template> <div id="app"> <vue-ruler-tool :content-layout="{left:200,top:100}" :is-scale-revise="true" :preset-line="presetLine" > <div class="test"></div> </vue-ruler-tool> </div> </template> <script> import VueRulerTool from 'vue-ruler-tool' export default { name: 'app', components:{ VueRulerTool }, data () { return { presetLine: [{ type: 'l', site: 100 }, { type: 'v', site: 200 }] } } } </script>
Props
positionnpm
类型:String
并发
默认值: relative
app
可能值:['absolute', 'fixed', 'relative', 'static', 'inherit']
wordpress
规定标尺工具的定位类型工具
<vue-ruler-tool :position="'fixed'" >
isHotKey布局
类型: Boolean
ui
默认值: true
快捷键键开关,目前仅支持快捷键R
标尺显示开关
<vue-ruler-tool :is-hot-key="ture" >
isScaleRevise
类型: Boolean
默认值: false
刻度修正(根据content进行刻度重置),意思就是从内容的位置开始从0计数
<vue-ruler-tool :is-scale-revise="ture" >
topSpacing
类型: Number
默认值: 0,
标尺与窗口的上间距,若是你的position
不为fixed
,此项必填
leftSpacing
类型: Number
默认值: 0
标尺与窗口的左间距,若是你的position
不为fixed
,此项必填
presetLine
类型: Array
默认值: []
接受格式: [{ type: 'l', site: 50 }, { type: 'v', site: 180 }]
预置参考线l
表明水平线,v
表明垂直线,site
为Number类型
<vue-ruler-tool :preset-line="[{ type: 'l', site: 100 }, { type: 'v', site: 200 }]" >
contentLayout
类型: Object
默认值: { top: 50, left: 50 }
内容部分布局分布,及内容摆放位置
<vue-ruler-tool :content-layout="{left:200,top:100}" >
Methods
quickGeneration
参数:[{ type: 'l', site: 100 }, { type: 'v', site: 200 }]
快速设置参考线,通常用来经过弹窗让用户输入
<vue-ruler-tool ref='rulerTool' > let params=[ { type: 'l', site: 100 }, { type: 'v', site: 200 } ] this.$refs.rulerTool.quickGeneration(params)