main.js
import elementResizeDetectorMaker from 'element-resize-detector';
Vue.use(elementResizeDetectorMaker);
index.js
let erd = elementResizeDetectorMaker();
erd.listenTo(document.getElementById("test"), function(element) {
var width = element.offsetWidth;
var height = element.offsetHeight;
console.log("Size: " + width + "x" + height);
});
错误信息
11:19:09.074 [system]ReferenceError: elementResizeDetectorMaker is not defined
at VueComponent.onLoad (webpack-internal:///C:\Users\Administrator\Desktop\RebateAPP\js\index.js:118:15)
at invokeWithErrorHandling (http://localhost:8080/static/js/chunk-vendors.js:5298:26)
at VueComponent.push../node_modules/@dcloudio/vue-cli-plugin-uni/packages/h5-vue/dist/vue.runtime.esm.js.Vue.__call_hook (http://localhost:8080/static/js/chunk-vendors.js:12040:17)
at r (http://localhost:8080/static/js/chunk-vendors.js:186:385335)
at a (http://localhost:8080/static/js/chunk-vendors.js:186:385977)
at VueComponent.created (http://localhost:8080/static/js/chunk-vendors.js:186:16884)
at invokeWithErrorHandling (http://localhost:8080/static/js/chunk-vendors.js:5298:57)
at callHook (http://localhost:8080/static/js/chunk-vendors.js:7704:7)
at VueComponent.Vue._init (http://localhost:8080/static/js/chunk-vendors.js:8489:23)
at new VueComponent (http://localhost:8080/static/js/chunk-vendors.js:8635:12)
1 个回复
越王够贱 (作者)
或者有没有其他监听view 高度变化的方法?