javascript - vue3 isCustomElement is detecting component as a vue component - Stack Overflow

I am trying to get a webponent working with vitejs.ponent I am trying to use:I did as describe in the

I am trying to get a webponent working with vitejs.

ponent I am trying to use:

I did as describe in the docs.

install and setup @vitejs/plugin-vue

initiate the customelement in config. ( I also tried simply putting the custom element in main.js

vite.config.js


import { VitePWA } from 'vite-plugin-pwa'
import vue from '@vitejs/plugin-vue'
export default {
  plugins: [
    VitePWA(),
    vue({
      template: {
        pilerOptions: {
          isCustomElement: tag => tag === 'input-knob'
        }
      }
    })
  ]
}



still getting the same warning :frowning:

app.config.isCustomElement = tag => tag.startsWith('input-')

console.log(app.config.isCustomElement('input-knob'))

main.js


import { createApp } from 'vue'
import App from './App.vue'
import './index.css'

const app = createApp(App);

app.config.isCustomElement = tag => tag.startsWith('input-')

console.log(app.config.isCustomElement('input-knob'))
app.mount('#app')


[Vue warn]: Failed to resolve ponent: input-knob

the log returns true, so I am not sure where the problem actually is.

I am trying to get a webponent working with vitejs.

ponent I am trying to use: https://www.webponents/element/input-knob

I did as describe in the docs.

install and setup @vitejs/plugin-vue

https://github./vitejs/vite/tree/main/packages/plugin-vue#vitejsplugin-vue-

initiate the customelement in config. ( I also tried simply putting the custom element in main.js https://github./vitejs/vite/issues/1312

vite.config.js


import { VitePWA } from 'vite-plugin-pwa'
import vue from '@vitejs/plugin-vue'
export default {
  plugins: [
    VitePWA(),
    vue({
      template: {
        pilerOptions: {
          isCustomElement: tag => tag === 'input-knob'
        }
      }
    })
  ]
}



still getting the same warning :frowning:

app.config.isCustomElement = tag => tag.startsWith('input-')

console.log(app.config.isCustomElement('input-knob'))

main.js


import { createApp } from 'vue'
import App from './App.vue'
import './index.css'

const app = createApp(App);

app.config.isCustomElement = tag => tag.startsWith('input-')

console.log(app.config.isCustomElement('input-knob'))
app.mount('#app')


[Vue warn]: Failed to resolve ponent: input-knob

the log returns true, so I am not sure where the problem actually is.

Share Improve this question asked Feb 26, 2021 at 11:28 Fanna1119Fanna1119 2,3265 gold badges29 silver badges32 bronze badges 3
  • Got also some problems webponents but with webpack. Which vue version do you use? Did you log also the vite part? pilerOptions: { isCustomElement: tag => tag === 'input-knob' } – ste-xx Commented Feb 26, 2021 at 18:13
  • It is the latest version. (i did not add the vite config) js "dependencies": { "@vitejs/plugin-vue": "^1.1.4", "@vueuse/core": "^4.2.2", "vue": "^3.0.4" }, "devDependencies": { "@vue/piler-sfc": "^3.0.4", "vite": "^1.0.0-rc.13", "vite-plugin-pwa": "^0.5.4" } } – Fanna1119 Commented Feb 27, 2021 at 14:41
  • How do I log vite? – Fanna1119 Commented Feb 27, 2021 at 14:45
Add a ment  | 

1 Answer 1

Reset to default 0

Problem was vite version. Pushing it to vite2 fixes this.

"vite": "^2.0.5"

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745272308a4619822.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信