mirror of
				https://gitee.com/vant-contrib/vant.git
				synced 2025-11-04 21:02:09 +08:00 
			
		
		
		
	Pre Merge pull request !2 from 崔明辉/feature/useRect
This commit is contained in:
		
						commit
						df1c988d15
					
				@ -13,15 +13,18 @@
 | 
				
			|||||||
```
 | 
					```
 | 
				
			||||||
 | 
					
 | 
				
			||||||
```js
 | 
					```js
 | 
				
			||||||
import { ref } from 'vue';
 | 
					import { ref,onMounted } from 'vue';
 | 
				
			||||||
import { useRect } from '@vant/use';
 | 
					import { useRect } from '@vant/use';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export default {
 | 
					export default {
 | 
				
			||||||
  setup() {
 | 
					  setup() {
 | 
				
			||||||
    const root = ref();
 | 
					    const root = ref();
 | 
				
			||||||
    const rect = useRect(root);
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
    console.log(rect); // -> 元素的大小及其相对于视口的位置
 | 
					    onMounted(()=>{
 | 
				
			||||||
 | 
					      const rect = useRect(root);
 | 
				
			||||||
 | 
					      console.log(rect); // -> 元素的大小及其相对于视口的位置
 | 
				
			||||||
 | 
					    })
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    return { root };
 | 
					    return { root };
 | 
				
			||||||
  },
 | 
					  },
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user