Invalid after iscustomelement configuration,There are test cases
Version
3.0.4
Reproduction link
https://github.com/ht-sauce/vuemini-test
Steps to reproduce
app.config.isCustomElement = tag => tag.startsWith('ion-') A minimum case has been provided according to the requirements in GitHub, please check
What is expected?
There should be no warning
What is actually happening?
There are still warnings
Maybe it's not a Vue bug, so I closed my PR. as a workround, edit babel.config.js like this:
module.exports = {
presets: [
'@vue/cli-plugin-babel/preset'
],
plugins: [
/* eslint-disable-next-line global-require */
[require('@vue/babel-plugin-jsx'), { isCustomElement: tag => /^ion-/.test(tag) }],
],
}
也许这不是Vue的错误,所以我关闭了PR。 作为工作场所,请像下面这样编辑babel.config.js:
模块。出口 = { 预设:[ '@ vue / cli-plugin-babel / preset' ] , 插件:[ / * eslint-disable-next-line global-require * / [要求('@ vue / babel-plugin-jsx' ), { isCustomElement:tag => / ^ ion- / 。测试(标签) } ] , ] , }
Thank you. That really solves the problem.
But this configuration does not appear in the official documents, I think there will be a lot of people like me have doubts. Hope to improve the official documents
We should probably amend the Vue core docs for app.config.isCustomElement
and explain that:
- This check only runs for templates compiled at runtime.
- a similar option can be configured for templates compiled during build:
- vue-loader & rollup-plugin-vue (through their
compilerOptions
) - vue's jsx babel plugin
Only adding the workaround from @edison1105 didn't work for me. (Reproduction Projekt: https://github.com/florianrusch/Foobar3)
I use @vue/cli
. If I understand correctly the PR of @Xenonym (https://github.com/vuejs/docs-next/pull/779) and the note he added to the docs, I have to use vue-loader
and thus a custom webpack configuration to set the compiler option. Is that correct? Or is there a way to set the compiler option without using vue-loader
/a custom webpack config?
I have to use vue-loader and thus a custom webpack configuration to set the compiler option @florianrusch yes
This is now documented better: https://vuejs.org/api/application.html#app-config-compileroptions
Closing this