Reputation: 403
It might be basic question,however I can't find the answer and I have no idea it is possible or not.
I am not familliar with vue
What I want to do is like this
<html>
[[parse()]]
</html>
new Vue({
methods: {
parse(){
return "<div>test</div>"
}
}
});
Normally it shows the <div>test<div>
as strings not html tags,
However I want to eval this return variable as html.
Is it possible?
Upvotes: 1
Views: 1126
Reputation: 806
Assuming that you're not using unconstrained user input in your HTML generation which could leave your page vulnerable to injection attacks, you can use the v-html directive for this:
<div v-html="parse()"></div>
Upvotes: 1