Skip to content

vue-doctor/correctness/no-direct-dom-manipulation ​

Use template refs: const el = ref<HTMLElement>() with ref="el" instead of document.querySelector()

PropertyValue
CategoryCorrectness
Default Severitywarning
Confidencemedium
FixableNo
Engineoxlint
Sincev1.0.0
Frameworksvue, nuxt
Test filesNot checked (which files)

Why it matters ​

Use template refs: const el = ref<HTMLElement>() with ref="el" instead of document.querySelector()

How to fix ​

Review the finding and update the code according to best practices below.

Agent Guidance ​

Use a template ref (const el = ref<HTMLElement | null>(null) with ref="el") and access el.value after mount instead of document.querySelector.


Rule source: vue-doctor/correctness/no-direct-dom-manipulation

Released under the MIT License.