<template>
<div :style="`width:${width}px;height:${height}px`">
<img :src="imgSrc" v-if="!isGray||!isIE11">
<div v-else>
<svg overflow="hidden" preserveAspectRatio="none slice" :width="width" :height="height">
<image overflow="visible" preserveAspectRatio="none slice" x='0' y='0' :width="width" :height="height" :xlink:href="imgSrc" filter="url(#grayscle)"></image>
</svg>
</div>
</div>
</template>
<script>
export default {
name:"grayImg",
props:{
imgSrc:{
type:String,
default:""
},
width:{
type:[Number,String],
default:150
},
height:{
type:[Number,String],
default:90
}
},
computed: {
isGray() {
return window.sessionStorage.getItem('skin')=='default';
},
isIE11(){
return navigator.userAgent.indexOf('Trident')!==-1;
}
},
}
</script>
<style lang="scss" scoped>
img{
height:100%;
width:100%;
}
</style>
// <template>
// <svg xmlns=" http://www.w3.org/2000/svg" style="display:none">
// <filter id="grayscale">
// <feColorMatrix type="matrix"values="0.3333 0.3333 0.3333 0 0 0.3333 0.3333 0.3333 0 0 0.3333 0.3333 0.3333 0 0 0 0 0 1 0"/>
// </filter>
// </svg>
// </template>
// <script>
// export default {
// name:"grayscale"
// }
// </script>
扫码关注腾讯云开发者
领取腾讯云代金券
Copyright © 2013 - 2025 Tencent Cloud. All Rights Reserved. 腾讯云 版权所有
深圳市腾讯计算机系统有限公司 ICP备案/许可证号:粤B2-20090059 深公网安备号 44030502008569
腾讯云计算(北京)有限责任公司 京ICP证150476号 | 京ICP备11018762号 | 京公网安备号11010802020287
Copyright © 2013 - 2025 Tencent Cloud.
All Rights Reserved. 腾讯云 版权所有