方法一: 1.定义变量 1 2 3 4 5 data(){ return{ formWidth : '123px' } }, 2.根据生命周期 在mounted 中绑定 窗口变化 1 2 3 4 5 6 7 8 9 mounted(){ const that = this window.onresize = () => { return (() => { window.screenWidth = document.body.clientWidth