vue.js實現(xiàn)照片放大功能
更新時間:2020年06月23日 11:24:18 作者:周小姐你好
這篇文章主要為大家詳細介紹了vue.js實現(xiàn)照片放大功能,文中示例代碼介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們可以參考一下
本文實例為大家分享了vue.js實現(xiàn)照片放大的具體代碼,供大家參考,具體內(nèi)容如下
這里就不放圖了,放大的是別人的身份證
<template>
<div class="image-cell__wrapper" :style="border">
<span class="title" :style="{color: titleColor}">{{ imageTitle }}</span>
<span class="icon-image"></span>
<span class="image-wrapper">
<img v-for="(item, key) in realImage" :src="imageHandle(item, 80, 80)" alt="image">
</span>
<span class="icon-arrow" v-if="arrow"></span>
<div v-if="inlineBorder"
class="inline-border"></div>
</div>
</template>
<script>
import { imgHandle } from '@/utils/tool'
export default {
name: 'imageCell',
props: {
imageTitle: {
type: String,
required: true
},
image: {
required: false
},
arrow: {
type: Boolean,
default: true
},
titleColor: {
type: String,
default: '#575fb6'
},
inlineBorder: {
type: Boolean,
default: false
},
hasBorder: {
type: Boolean,
default: false
}
},
data () {
return {
border: {
borderBottom: this.hasBorder ? '1px solid #ececec' : ''
}
}
},
created () {
},
computed: {
realImage () {
if (this.image) {
return this.image.length > 5 ? this.image.slice(0, 5) : this.image
}
}
},
methods: {
imageHandle (url, w, h) {
return imgHandle(url, w, h)
}
}
}
</script>
<style lang="stylus" scoped>
@import "~@/assets/mixin.stylus"
.image-cell__wrapper{
position relative
width 9rem
padding 0 .5rem
height 1.5rem
line-height 1.5rem
background-color white
font-dpr(16px)
color #4A4A4A
.title{
color #575fb6
}
.icon-image{
display inline-block
width .5rem
height .4rem
bg-image('./img/picture')
background-size contain
vertical-align middle
}
.image-wrapper{
display inline-block
position absolute
right 1rem
img{
display inline-block
vertical-align middle
padding-left .3rem
width .6rem
height .6rem
}
}
.icon-arrow{
position relative
top .6rem
float right
display inline-block
width .2rem
height .4rem
bg-image('~@/assets/img/arrow')
background-size contain
}
.inline-border{
position absolute
bottom 0
left .4rem
width 9.6rem
height 1px
background-color #ECECEC
}
}
</style>
tool.js里面的imgHandle
@function imgHandle 切割圖片
function imgHandle (url, width, height) {
const fontSize = document.documentElement.style.fontSize.split('px')[0]
return url + '?imageView2/1/w/' + (fontSize / 75 * width * 5).toFixed(0) + '/h/' + (fontSize / 75 * height * 5).toFixed(0) + '/q/100'
}
export { imgHandle }
export default { imgHandle }
關于vue.js組件的教程,請大家點擊專題vue.js組件學習教程進行學習。
以上就是本文的全部內(nèi)容,希望對大家的學習有所幫助,也希望大家多多支持腳本之家。
相關文章
vue+element 多個相同的select不允許重復選擇問題
這篇文章主要介紹了vue+element 多個相同的select不允許重復選擇問題,具有很好的參考價值,希望對大家有所幫助。2022-07-07
vue表單驗證你真的會了嗎?vue表單驗證(form)validate
這篇文章主要介紹了vue表單驗證你真的會了嗎?vue表單驗證(form)validate,文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友們下面隨著小編來一起學習學習吧2019-04-04
使用Vue?Query實現(xiàn)高級數(shù)據(jù)獲取的示例詳解
構建現(xiàn)代大規(guī)模應用程序最具挑戰(zhàn)性的方面之一是數(shù)據(jù)獲取,這也是?Vue?Query?庫的用途所在,下面就跟隨小編一起學習一下如何利用Vue?Query實現(xiàn)高級數(shù)據(jù)獲取吧2023-08-08
webpack項目調(diào)試以及獨立打包配置文件的方法
下面小編就為大家分享一篇webpack項目調(diào)試以及獨立打包配置文件的方法,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧2018-02-02

