|
|
|
@ -1,7 +1,7 @@
|
|
|
|
|
/*
|
|
|
|
|
* @Author: your name
|
|
|
|
|
* @Date: 2021-10-12 13:56:13
|
|
|
|
|
* @LastEditTime: 2021-11-03 17:03:23
|
|
|
|
|
* @LastEditTime: 2021-11-05 11:38:47
|
|
|
|
|
* @LastEditors: Please set LastEditors
|
|
|
|
|
* @Description: In User Settings Edit
|
|
|
|
|
* @FilePath: /data-show/src/mixins/index.js
|
|
|
|
@ -31,6 +31,18 @@ function detectZoom (){
|
|
|
|
|
|
|
|
|
|
return ratio;
|
|
|
|
|
}
|
|
|
|
|
function adaptive(el,z) {
|
|
|
|
|
const style = document.defaultView.getComputedStyle(el); // 获取元素
|
|
|
|
|
const wh = document.body.clientHeight;
|
|
|
|
|
let h = style.height;
|
|
|
|
|
if(wh >= 760) {
|
|
|
|
|
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({
|
|
|
|
@ -56,33 +68,12 @@ export default {
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
highly: {
|
|
|
|
|
bind(el) { // el为绑定的元素,binding为绑定给指令的对象
|
|
|
|
|
// console.log(el, "绑定", binding);
|
|
|
|
|
let h = ""
|
|
|
|
|
function adaptive() {
|
|
|
|
|
const style = document.defaultView.getComputedStyle(el); // 获取元素
|
|
|
|
|
const wh = document.body.clientHeight;
|
|
|
|
|
const height = style.height;
|
|
|
|
|
let z = 1;
|
|
|
|
|
let gh = 1080;
|
|
|
|
|
if(wh >= gh) {
|
|
|
|
|
z = 1;
|
|
|
|
|
} else if(wh >= 760 && wh < gh) {
|
|
|
|
|
z = wh / gh
|
|
|
|
|
} else {
|
|
|
|
|
z = 760 / gh
|
|
|
|
|
}
|
|
|
|
|
if( h !== style.height) {
|
|
|
|
|
el.style.height = z * parseFloat(height) + 'px';
|
|
|
|
|
h = style.height;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
adaptive()
|
|
|
|
|
bind(el, binding) { // el为绑定的元素,binding为绑定给指令的对象
|
|
|
|
|
adaptive(el, binding.value)
|
|
|
|
|
// el.__vueSetInterval__ = setInterval(adaptive, 300);
|
|
|
|
|
},
|
|
|
|
|
unbind(el) {
|
|
|
|
|
// console.log(el, "解绑");
|
|
|
|
|
clearInterval(el.__vueSetInterval__);
|
|
|
|
|
inserted(el, binding) {
|
|
|
|
|
adaptive(el, binding.value)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|