JS.VUE.NO.CHILD.CONTENT
No child content of element
- Some problems reported by this rule are manually fixable by editor suggestions (https://eslint.org/docs/developer-guide/working-with-rules#providing-suggestions).
Rule Details
This rule reports child content of elements that have a directive which overwrites that child content. By default, those are v-html
and v-text
, additional ones (e.g. Vue I18n's v-t
directive (https://vue-i18n.intlify.dev/api/directive.html)) can be configured manually.
{'vue/no-child-content': ['error']}
Copy
<template>
<!-- GOOD -->
<div>child content</div>
<div v-html="replacesChildContent"></div>
<!-- BAD -->
<div v-html="replacesChildContent">child content</div>
</template>
Options
Copy
{
"vue/no-child-content": ["error", {
"additionalDirectives": ["foo"] // checks v-foo directive
}]
}
additionalDirectives
... An array of additional directives to check, without thev-
prefix. Empty by default;v-html
andv-text
are always checked.
Further Reading
v-html
directive (https://vuejs.org/api/built-in-directives.html#v-html)v-text
directive (https://vuejs.org/api/built-in-directives.html#v-text)