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+element 多個(gè)相同的select不允許重復(fù)選擇問(wèn)題
這篇文章主要介紹了vue+element 多個(gè)相同的select不允許重復(fù)選擇問(wèn)題,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。2022-07-07
vue表單驗(yàn)證你真的會(huì)了嗎?vue表單驗(yàn)證(form)validate
這篇文章主要介紹了vue表單驗(yàn)證你真的會(huì)了嗎?vue表單驗(yàn)證(form)validate,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧2019-04-04
使用Vue?Query實(shí)現(xiàn)高級(jí)數(shù)據(jù)獲取的示例詳解
構(gòu)建現(xiàn)代大規(guī)模應(yīng)用程序最具挑戰(zhàn)性的方面之一是數(shù)據(jù)獲取,這也是?Vue?Query?庫(kù)的用途所在,下面就跟隨小編一起學(xué)習(xí)一下如何利用Vue?Query實(shí)現(xiàn)高級(jí)數(shù)據(jù)獲取吧2023-08-08
Vue前端開(kāi)發(fā)之實(shí)現(xiàn)交錯(cuò)過(guò)渡動(dòng)畫(huà)效果
這篇文章主要為大家詳細(xì)介紹了如何通過(guò)Vue實(shí)現(xiàn)交錯(cuò)過(guò)渡動(dòng)畫(huà)效果,文中的示例代碼講解詳細(xì),感興趣的小伙伴可以跟隨小編一起學(xué)習(xí)一下2024-11-11
webpack項(xiàng)目調(diào)試以及獨(dú)立打包配置文件的方法
下面小編就為大家分享一篇webpack項(xiàng)目調(diào)試以及獨(dú)立打包配置文件的方法,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過(guò)來(lái)看看吧2018-02-02

