组件用.vue还是.js_Vue.js的滑出组件

组件用.vue还是.js

滑出 (SlideOut)

A Slide-Out component for Vue.js 2.0.

Vue.js 2.0的Slide-Out组件。

依存关系 (Dependencies)

  • Vue.js 2.x

    Vue.js 2.x

  • Less

  • v-scroll-lock

    v滚动锁定

安装 (Install)

npm i @hyjiacan/vue-slideout

or

要么

yarn add @hyjiacan/vue-slideout

For the latest code, you can:

对于最新的代码,您可以:

git clone https://github.com/hyjiacan/vue-slideout.git

or download archive

下载档案

用法 (Usage)

<slide-out @close="onClose">
    <div slot="header" slot-scope="{title}">
    </div>
    content
</slide-out>
<script>
import SlideOut from '@hyjiacan/vue-slideout'
import from '@hyjiacan/vue-slideout/lib/vue-slideout.css'

export default {
    name: 'Foobar',
    components: {SlideOut},
    methods: {
        onClose (e) {
            // prevent close and wait
            e.wait = true
            // close after 3 seconds
            setTimeout(() => {
                // assign true to close, do nothing or assign false to cancel close.
                e.close = true
            }, 3000)
        }
    }
}
</script>

You can register it into global with Vue.component(SlideOut.name, SlideOut) or Vue.use(SlideOut)

您可以使用Vue.component(SlideOut.name, SlideOut)Vue.use(SlideOut)将其注册到全局

For more usage, see https://hyjiacan.github.io/vue-slideout/

有关更多用法,请参见https://hyjiacan.github.io/vue-slideout/

物产 (Properties)

nametyperequireddescriptiondefault
sizeString/NumberNOThe size of slide, both px and % available400px
zIndexNumberNOThe z-index of slide1997
visibleBooleanYESIs the slide visible,modifier .sync is availablefalse
titleStringNOSlide title text, if this is empty and slot=header is empty too,
the header would be hidden
-
closeOnMaskClickBooleanNOWhether to close slide while mask clickedtrue
customClassStringNOCustomized stylesheet class name-
showMaskBooleanNOIs mask visibletrue
maskColorStringNOMask colorrgba(0, 0, 0, 0.5)
dockStringNOSlide dock position, optional values: top, right, bottom, leftright
appendToString/HTMLElementNOAppend slide into specified element.Both string(selector) and
HTMLElement(DOM object) available
null
disableAnimationBooleanNOWhether to disable animationfalse
allowResizeBooleanNOWhether to allow drag-resizefalse
minSizeNumberNOThe min limit of drag-resize, value in px60
maxSizeNumberNOThe max limit of drag-resize, value 0 makes no limit, value in px0
ignoreEscBooleanNOWhether to ignore esc key, set false or keep default to close slide while press ESCfalse
lockScrollBooleanNOWhether to lock page (affected to body element only) scroll (except slide self)false
名称 类型 需要 描述 默认
尺寸 字符串/数字 没有 幻灯片的大小,可用px% 400像素
索引 没有 幻灯片的Z索引 1997年
可见 布尔型 幻灯片是否可见,修饰符.sync可用
标题 没有 幻灯片title文本(如果为空且slot=header也为空),
标头将被隐藏
--
closeOnMaskClick 布尔型 没有 单击蒙版时是否关闭幻灯片 真正
customClass 没有 自定义样式表类名称 --
显示面具 布尔型 没有 遮罩可见吗 真正
maskColor 没有 面膜颜色 rgba(0,0,0,0.5)
码头 没有 滑动底座位置,可选值: toprightbottomleft
appendTo 字符串/ HTMLElement 没有 将幻灯片追加到指定的元素中。 string (选择器)和
HTMLElement (DOM对象)可用
空值
disableAnimation 布尔型 没有 是否禁用动画
allowResize 布尔型 没有 是否允许拖动调整大小
最小尺寸 没有 拖动调整大小的最小限制,以px 60
maxSize 没有 拖动调整大小的最大限制,值0无限制,以px 0
ignoreEsc 布尔型 没有 在按ESC是忽略esc键,设置为false还是保留默认值以关闭幻灯片
lockScroll 布尔型 没有 是否锁定页面(仅影响到body元素)滚动(幻灯片自身除外)

Note: Slide uses style position: fixed and lock body scroll if property appendTo not specified.

注意:幻灯片使用样式position: fixed如果未指定属性appendToposition: fixed并锁定body滚动。

插槽 (Slots)

namescopedescription
header{title}Header content, take all the header bar,
title will take no affected(and close button will be removed) if specified this,
use slot-scope="{ title }" to get property title
default-Content
footer-Footer content
名称 范围 描述
标头 {title} 标题内容,占据所有标题栏,
如果指定此titletitle将不受影响(并且关闭按钮将被删除),
使用slot-scope="{ title }"获取属性title
默认 -- 内容
页脚 -- 页脚内容

大事记 (Events)

nameparameterdescription
open-Invoke after slide opened
closee: {close: Boolean, wait: Boolean}Invoke before slide close, in callback function,
assign e.wait=true to prevent close,
and assign e.close=true to close (async supported)
closed-Invoke after slide really closed, it's emit after event close
名称 参数 描述
打开 -- 幻灯片打开后调用
e: {close: Boolean, wait: Boolean} 在幻灯片关闭之前调用,在回调函数中,
分配e.wait=true以防止关闭,
并分配e.close=true以关闭(支持异步)
关闭 -- 幻灯片真正关闭后调用,事件close后发出

发展历程 (Development)

yarn
# start dev server
yarn run serve
# Build library
yarn run release

翻译自: https://vuejsexamples.com/a-slide-out-component-for-vue-js/

组件用.vue还是.js

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值