1

The Requirement is to append an HTML element from Array Value to DOM

template: {
    0: {
       h1: '<h1>Hi</h1>'
    },
    1: {
       h2: '<h2>Hi</h2>'
    },
    2: {
       h3: '<h3>Hi</h3>'
    }
}

I have a VueJS For Loop:

        <div v-for="temp in template">
            {{ temp.h1}}
        </div>

DOM :

<h1>hi</h1>
2
  • You need to elaborate more on your problem. What are you actually trying to achieve? Commented Sep 13, 2017 at 10:19
  • i want to append array value to DOM, with HTML querys Commented Sep 13, 2017 at 10:20

1 Answer 1

1

I think you need to use v-html binding to inject raw html in page.

Something like this:

<div v-for="temp in template">
    <div v-html="temp.h1">
</div>

Check here for more info: https://v2.vuejs.org/v2/guide/syntax.html#Raw-HTML

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.