I need to find a way to use a VueJS variable in a style attribute, as example when I try something like <p style="color:[% randomColor() %];></p> it dissapears on my console.
Here's an example on fiddle : https://jsfiddle.net/Lindow/bjfvdgde/3/
HTML :
<div id="app">
<p style="color:[% randomColor() %];">[% nameAttr() %]</p>
</div>
JavaScript :
var color = new Vue({
el:'#app',
methods:{
nameAttr:function(){
var name = 'John Doe';
return name
},
randomColor:function(){
var font_color = "red";
return font_color
}
},
delimiters: ["[%","%]"]
});
How can I get around this problem ?