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

Error 'Unknown custom element: <vue-json-pretty>' #24

Closed
duduindo opened this issue Apr 5, 2019 · 2 comments
Closed

Error 'Unknown custom element: <vue-json-pretty>' #24

duduindo opened this issue Apr 5, 2019 · 2 comments

Comments

@duduindo
Copy link

duduindo commented Apr 5, 2019

JSBin

https://jsbin.com/fomudog/edit?html,console

Console

"[Vue warn]: Unknown custom element: <vue-json-pretty> - did you register the component correctly? For recursive components, make sure to provide the \"name\" option.

found in

---> <App>
       <Root>"

Code

// App
const App = Vue.component('app', {
  render(create) {
    return create('div', [
      create('vue-json-pretty', {
        props: {              
          data: "{ key: 'value' }"
        }
      })
    ])
  }      
})

// Use    
Vue.use(VueJsonPretty)
      
// Instance
new Vue({        
  render(create) {
    return create(App)
  }
}).$mount('#app')
@duduindo
Copy link
Author

duduindo commented Apr 6, 2019

My Solution

JSBin

https://jsbin.com/sizowup/edit?html,output

Code

// App
const App = Vue.component('app', {
  render(create) {
    return create('div', [
      create('vue-json-pretty', {
        props: {                           
          data: { 
            key: 'value',
            first: 'Hello, World!',
          }
        }
      })
    ])
  }      
})

/**
 * HERE
 */
// Use    
// Vue.use(VueJsonPretty)
Vue.component('vue-json-pretty', VueJsonPretty.default)

      
// Instance
new Vue({        
  render(create) {
    return create(App)          
  }
}).$mount('#app')

Difference

From:

// Use    
Vue.use(VueJsonPretty)

To:

// Use    
// Vue.use(VueJsonPretty)
Vue.component('vue-json-pretty', VueJsonPretty.default) // Why 'default'?

@leezng
Copy link
Owner

leezng commented Apr 9, 2019

See the differences between CommonJS and ESModule

@leezng leezng closed this as completed Apr 9, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants