Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unknown custom element #39

Open
shaneblaser opened this issue Nov 17, 2019 · 6 comments
Open

Unknown custom element #39

shaneblaser opened this issue Nov 17, 2019 · 6 comments
Assignees
Labels
bug Something isn't working

Comments

@shaneblaser
Copy link

Following the instructions in a read me I get the following error

vue.runtime.esm.js?2b0e:619 [Vue warn]: Unknown custom element: - did you register the component correctly? For recursive components, make sure to provide the "name" option.

@morphatic morphatic added the bug Something isn't working label Nov 17, 2019
@morphatic morphatic self-assigned this Nov 17, 2019
@morphatic
Copy link
Owner

Yeah, I've noticed this, but haven't figured out what's wrong yet. This only happens if you try to import it inside of a single component, but not if you register it globally. To register it globally:

// src/main.js

// ...after your other standard imports...

// make sure you're using vuetify--see their docs for details on proper installation
import vuetify from '@/plugins/vuetify'

// import the library
import VStripeElements from 'v-stripe-elements/lib'
// and register it
Vue.use(VStripeElements)

// then initialize your app as normal
new Vue({
  vuetify,
  render: h => h(App)
}).$mount('#app')

Then in your component, you shouldn't have to import it. Just use it, e.g.

// src/components/SomeComponent.vue
<template>
  <div>
    <v-stripe-card
      v-model="cardSource"
      :api-key="apiKey"
      create="source"
    />
  </div>
</template>

<script>
  export default {
    name: 'SomeComponent',
    data: () => ({
      apiKey: process.env.VUE_APP_STRIPE_API_KEY,
      cardSource: null
    })
  }
</script>

Thanks for reporting, though! I think it's a pretty simple fix, but I haven't had time to look at it.

@shaneblaser
Copy link
Author

shaneblaser commented Nov 18, 2019 via email

@shaneblaser
Copy link
Author

shaneblaser commented Dec 31, 2019 via email

@alexrussell
Copy link

alexrussell commented Feb 14, 2020

I managed to get around this by just importing the component directly:

<template>
  <div>
    <v-stripe-card />
  </div>
</template>
<script>
import VStripeCard from 'v-stripe-elements/lib/VStripeCard'

export default {
  components: { VStripeCard },
}
</script>

Not absolutely ideal but better than a global registration for me until the export issue is resolved.

(Though, actually due to this component's non-use of Vuetify's form validation without extra effort and token creation on blur only I may have to use something else anyway.)

@gsidsid
Copy link

gsidsid commented Jun 22, 2020

Did anyone find out a way to do this with Nuxt? I'm stuck getting "Cannot use import statement outside module" errors, despite trying to put in a plugin and using the transpile option.

@DArrigoni
Copy link

Had this issue and using import VStripeCard from 'v-stripe-elements/lib/VStripeCard'; fixed my problem as well. However, I had a slightly different error message:

vue.runtime.esm.js?2b0e:619 [Vue warn]: Failed to mount component: template or render function not defined.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

5 participants