如果我们给一个div设定全屏背景图,就需要获取屏幕高度进行赋值:
<template> <div ref="nana"> <!-- ... --> </div> </template> <script> export default { mounted () { let w = window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth; let h = window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight; this.$refs.nana.style.height = h +'px'; } } </script>