Sercan Paspal
Sercan Paspal

Reputation: 98

print vue component from string

This example is not working, is there any solution or usage is illegal?

Vue.component('hello', {
    template: '<span>Hello world!</span>'
})
Vue.component('foo', {
    data(){
        return {
            say_hello: '<hello></hello>'
        }
    },
    template: '<div v-html="say_hello"></div>'
})

Upvotes: 0

Views: 401

Answers (1)

bbsimonbb
bbsimonbb

Reputation: 28982

No that's not supported. The content of v-html is not processed by Vue, so no vue components, tags or bindings can be used there.

In general, if you see any markup outside of a template, it's an anti-pattern. And v-html is something you should use rarely and with a bad conscience :-)

Upvotes: 1

Related Questions