mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-11-04 04:42:09 +08:00
fix:元素的引用需要在onMounted里面操作
This commit is contained in:
parent
b521f73f7d
commit
c155ae6c8e
@ -13,15 +13,18 @@
|
||||
```
|
||||
|
||||
```js
|
||||
import { ref } from 'vue';
|
||||
import { ref,onMounted } from 'vue';
|
||||
import { useRect } from '@vant/use';
|
||||
|
||||
export default {
|
||||
setup() {
|
||||
const root = ref();
|
||||
const rect = useRect(root);
|
||||
|
||||
console.log(rect); // -> 元素的大小及其相对于视口的位置
|
||||
onMounted(()=>{
|
||||
const rect = useRect(root);
|
||||
console.log(rect); // -> 元素的大小及其相对于视口的位置
|
||||
})
|
||||
|
||||
|
||||
return { root };
|
||||
},
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user