移動端Vue.js圖片預覽插件

vue-picture-preview

移動端Vue.js圖片預覽插件 | Mobile-friendly picture file preview Vue.js plugin with horizontal nav and bottom title.javascript

Github Github Github

License vue-picture-preview NPM downloads NPM downloads

img

安裝

NPM

npm install --save vue-picture-preview

使用

首先在項目的入口文件中引入, 調用 Vue.use 安裝。css

import vuePicturePreview from 'vue-picture-preview'
Vue.use(vuePicturePreview)

在根組件添加 lg-preview 組件的位置vue

<!-- Vue root compoment template -->
<div id="app">
    <router-view></router-view>
    <lg-preview></lg-preview>
</div>

對於全部圖片均可以使用 v-preview 指令來綁定他們的預覽功能java

<img v-for="(img,index) in imgs" 
     v-preview="img.url" 
     :src="img.url" 
     :alt="img.title" 
     :key="index"
     preview-title-enable="true"
     preview-nav-enable="true">
export default {
    data () {
        return {
            imgs: [
                {
                  url: 'http://covteam.u.qiniudn.com/ka2.jpg',
                  title: 'pic1'
                },
                {
                  url: 'http://covteam.u.qiniudn.com/poster.png',
                  title: 'pic2'
                }
            ]
        }
    }
}
<style scoped>
img {
   width: 100%;
   height: 100%;
}
</style>

API

  • isTitleEnable: (boolean, optional) 設置 preview-title-enable="false" 將禁用底部標題. 默認值: true.
  • isHorizontalNavEnable: (boolean, optional) 設置 preview-nav-enable="false" 將禁用水平導航. 默認值: true.
相關文章
相關標籤/搜索