# Vue學習#21 refs ###### tags: `Vue 直播班 - 2022 春季班` ## 什麼是 refs 透過 `refs` 可以操作 DOM 元素的方法或是操作元件的 method 、 data ## 使用方法 ### 1. 在 HTML 或是元件標籤內加入 `ref="自定義名稱"`   ### 2. 透過這個 ref 自定義名稱就可以操作方法或是資料 , 語法為 `this.$refs.自定義名稱` + 想操作的方法或是 data card 是一個元件,透過 `refs` 更改元件的資料  透過 `refs` 操作 `input` DOM 元素,並執行 focus()  ## 透過 refs 利用 JS 操作 Bootstrap5 的 Modal 等等元件 ### [傳送門](https://hackmd.io/t6ZySuilRxacVjPbjrXncA)
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up