vue.js實(shí)現(xiàn)照片放大功能
本文實(shí)例為大家分享了vue.js實(shí)現(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 }
關(guān)于vue.js組件的教程,請(qǐng)大家點(diǎn)擊專題vue.js組件學(xué)習(xí)教程進(jìn)行學(xué)習(xí)。
以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。
相關(guān)文章
Vue+Java+Base64實(shí)現(xiàn)條碼解析的示例
這篇文章主要介紹了Vue+Java+Base64實(shí)現(xiàn)條碼解析的示例,幫助大家實(shí)現(xiàn)條碼解析,感興趣的朋友可以了解下2020-09-09
修改vue源碼實(shí)現(xiàn)動(dòng)態(tài)路由緩存的方法
這篇文章主要介紹了修改vue源碼實(shí)現(xiàn)動(dòng)態(tài)路由緩存的方法,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2020-01-01
Vue源碼解析之?dāng)?shù)據(jù)響應(yīng)系統(tǒng)的使用
這篇文章主要介紹了Vue源碼解析之?dāng)?shù)據(jù)響應(yīng)系統(tǒng)的使用,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2019-04-04
ElementUI如何修改Dialog的標(biāo)題樣式
這篇文章主要介紹了ElementUI如何修改Dialog的標(biāo)題樣式問題,具有很好的參考價(jià)值,希望對(duì)大家有所幫助,如有錯(cuò)誤或未考慮完全的地方,望不吝賜教2023-10-10
解決echarts echarts數(shù)據(jù)動(dòng)態(tài)更新和dataZoom被重置問題
這篇文章主要介紹了解決echarts echarts數(shù)據(jù)動(dòng)態(tài)更新和dataZoom被重置問題,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過來看看吧2020-07-07

