[Vuejs]-Evaluate a class binding to string?

0👍

You can bind the class to a function, rather than literals. For instance:

:class="getClasses"

where the function is computed:

computed: {
    getClasses: function() {
        return 'string-class test-case-class'
    },

You can then use it just like any other computed function:

{{ getClasses }}

Should show the string literal ‘string-class test-case-class’.

👤Joe Z

Leave a comment