组件用.vue还是.js_灵感源自灯箱的Vue.js组件

组件用.vue还是.js

静音盒 (silentbox)

A second version of the lightweight lightbox inspired component for Vue.js with local video support and more comming.

用于Vue.js的受轻量级灯箱启发的组件的第二版,具有本地视频支持和更多功能。

安装 (Installation)

Npm (Npm)

npm install --save vue-silentbox

Import the plugin into Vue:

将插件导入Vue:

import Vue from 'vue'
import VueSilentbox from 'vue-silentbox'

Vue.use(VueSilentbox)


如何使用? (How to use?)

Define an array of images in the data object of your Vue instance or component.

在Vue实例或组件的数据对象中定义图像数组。

const app = new Vue({
    el: '#application',
    data: {
        images: [
            {
                src: 'images/image001.jpg',
                description: 'Sunken dreams II. by Arbebuk',
            },
            {
                src: 'images/image002.jpg',
                description: 'Tunnel View Sunrise by Porbital',
            }
        ]
    },
})

Then in the template you can use a silent-box component to display gallery.

然后,在模板中,您可以使用silent-box组件来显示画廊。

<silent-box :gallery="images"><!-- your additional content --></silentbox-single>

or to show single image by just renaming the property.

或仅通过重命名属性来显示单个图像。

<silent-box :image="images[0]"><!-- your additional content --></silentbox-single>

图像对象属性 (Image object attributes)

You can set following attributes to the image object to change the behaviour of the SilentBox or display additional information. On the other hand, if you're lazy, only src attribute is required.

您可以为图像对象设置以下属性,以更改SilentBox的行为或显示其他信息。 另一方面,如果您很懒,则仅需要src属性。

AttributerequiredtypeDescription
srcyesstringmedia source, it could be an image or a youtube / Vimeo video
thumbnailnostringimage used for thumbnail
thumbnailHeightnostringheight of the thumbnail in px
thumbnailWidthnostringwidth of the thumbnail in px
descriptionnostringshort description below image (doesn't work below videos yet)
altnostringalt description for images
autoplaynoboolto autoplay youtube / Vimeo video
controlsnoboolworks only for youtube videos, setting false will hide video controls
属性 需要 类型 描述
src 媒体来源,它可以是图片或youtube / Vimeo视频
缩图 没有 用于缩略图的图像
thumbnailHeight 没有 缩略图的高度(以像素为单位)
thumbnailWidth 没有 缩略图的宽度(以像素为单位)
描述 没有 图片下方的简短说明(尚不能在视频下方使用)
alt 没有 图片的替代说明
自动播放 没有 布尔 自动播放youtube / Vimeo视频
控制项 没有 布尔 仅适用于youtube视频 ,设置为false会隐藏视频控件

支持的服务和格式 (Supported services and formats)

  • All image formats that can be displayed in browser

    可以在浏览器中显示的所有图像格式

  • Local video files with following extensions .mp4, .ogg, .webm, .mov, .flv, .wmv, .mkv

    具有以下扩展名的本地视频文件.mp4,.ogg,.webm,.mov,.flv,.wmv,.mkv

  • YouTube and Viemo embed videos with autoplay

    YouTube和Viemo嵌入具有自动播放功能的视频



从0.1升级? (Upgrading from 0.1?)

Version 2 brought many breaking changes. There are no more two separate components to display single image or gallery. So, change all your silentbox-group and silentbox-single components to silent-box. Source of images must be an array of objects or single object with previously mentioned attributes.

第2版​​带来了许多重大更改。 没有更多两个单独的组件来显示单个图像或画廊。 因此,将所有silentbox-groupsilentbox-single组件更改为silent-box 。 图像源必须是对象数组或具有前面提到的属性的单个对象。

翻译自: https://vuejsexamples.com/a-lightbox-inspired-vue-js-component/

组件用.vue还是.js

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值