prod
lily.zhang 3 years ago
parent 2058ab2127
commit 62e8544023

@ -1,7 +1,7 @@
/*
* @Author: your name
* @Date: 2021-10-12 13:56:13
* @LastEditTime: 2021-11-08 11:17:30
* @LastEditTime: 2021-11-08 12:03:25
* @LastEditors: Please set LastEditors
* @Description: In User Settings Edit
* @FilePath: /data-show/src/mixins/index.js
@ -32,19 +32,7 @@ function detectZoom (){
return ratio;
}
function adaptive(el,z) {
const style = document.defaultView.getComputedStyle(el); // 获取元素
const wh = document.body.clientHeight;
console.log(2222)
let h = style.height;
if(wh >= 760 && wh < 930) {
el.style.height = z * parseFloat(h) + 'px';
}
// if( h !== style.height) {
// el.style.height = z * parseFloat(height) + 'px';
// h = style.height;
// }
}
export default {
install(Vue) {
Vue.mixin({
@ -70,12 +58,34 @@ export default {
}
},
highly: {
bind() { // el为绑定的元素binding为绑定给指令的对象
// adaptive(el, binding.value)
// el.__vueSetInterval__ = setInterval(adaptive, 300);
bind(el, binding) { // el为绑定的元素binding为绑定给指令的对象
let height = '';
let z = binding.value;
let firstH = "";
let b = true;
function adaptive() {
const style = document.defaultView.getComputedStyle(el); // 获取元素
const wh = document.body.clientHeight;
let h = style.height;
firstH = firstH || h;
if (height == wh) return
if(wh >= 760 && wh < 930 && b) {
el.style.height = z * parseFloat(h) + 'px';
b = !b
} else {
el.style.height = firstH;
b = !b;
}
height = wh
}
el.__vueSetInterval__ = setInterval(adaptive, 300);
},
inserted(el, binding) {
adaptive(el, binding.value)
// inserted(el, binding) {
// adaptive(el, binding.value)
// },
unbind(el) {
// console.log(el, "解绑");
clearInterval(el.__vueSetInterval__);
}
}
},

Loading…
Cancel
Save