egoist / vue-html

An alternative to Vue template and Vue JSX

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Template string with component

rbajaniya opened this issue · comments

Hello,

I have render html with your plugin then it works fine with normal html but I have create one component for ex. Breadcrumb and render html with component but it not working. Please help me if it is possible.

=> For more help please review my code

<script>
import Breadcrumb from '~components/Breadcrumb'
import Vue from 'vue'
import HTML from 'vue-html'

Vue.use(HTML)

export default {
  data () {
    return {
      html: '<div><Breadcrumb/></div>'
    }
  },
  render (h) {
    return this.$html(this.html)
  },
  components: {
    Breadcrumb
  }
}
</script>

You have to use tagged template string like this.$html`${this.html}`

this.$html${this.html} put inside render function?

Yeah, that's what you should return in render function, basically it creates vnode from given string.

It's gives error

Syntax Error: Unexpected token, expected ; (24:22)

  22 |   },
  23 |   render (h) {
> 24 |     return this.$html${this.html}
     |                       ^
  25 |   },
  26 |   components: {
  27 |     Breadcrumb

You forgot backticks

Ohhh sorry,

I have put with backticks then resolved error but in browser not render template.