Vue的$ref使用Options之兩種寫法


Posted by hotmaneil on 2023-11-28

在Vue2時一直使用 Options(選項式)的寫法,Vue3 推出Composition(組合式)的新寫法。
在這裡的重點是放在ref使用 Options(選項式)的兩種寫法,特別筆記下來

第一種

this.$refs['formRef'].validate()

第二種

this.$refs.formRef.validate()

參考來源:

https://vuejs.org/guide/essentials/template-refs.html


#Vue







Related Posts

Vite系列# 環境變數設置

Vite系列# 環境變數設置

[Note] webpack 5 problem: Refused to execute script because its MIME type ('text/html') is not executable

[Note] webpack 5 problem: Refused to execute script because its MIME type ('text/html') is not executable

component test 問題集4(React18 + TS + Jest + react-testing-library)

component test 問題集4(React18 + TS + Jest + react-testing-library)


Comments