When dealing with the :class
attribute, it is recommended to have the getStyle
function (although poorly named) return a string that represents a CSS class. This CSS class will assign a background (in this simple scenario) to any element containing that class.
Therefore, the text "hello world" remains unchanged
For example, you can modify the computed property like:
computed:{
getStyle() {
return "custom-style";
},
},
and include the following style definition:
<style>
.custom-style {
background: #8898;
}
</style>
edit: consider using the :style attribute instead
<p :style="getStyle"> hello world </p>
The updated computed property might look something like this:
computed:{
getStyle() {
return { background: "#8898" };
},
},