2024年6月12日发(作者:)
vue ref 获取默认宽度
1. 在 DOM 元素上使用 vue 的 `$refs` 来获取宽度:
```html
My Element
```
```js
// 获取 div 的宽度
let width = this.$Width;
```
2. 如果你要使用 CSS 的方法,请使用 `putedStyle()` 方法:
```html
My Element
```
```js
let element = elector(".some-class");
let width = putedStyle(element).width;
```


发布评论