Methods in computed cannot call each other

computed : {

        count(){

            var a = this.incrpement;

            return ++a;

        },

        stylePadding(){//需要实时变化

            return {

                'padding-left' : (this.count() * 16) +'px'

            }

        }

    }

image

You don’t call the computed property like a function. It’s referenced as a value.

'padding-left' : (this.count * 16) +'px'
1 Like

Hello @mengxingedu,

computed are cached functions. you do not need to call them like this.count() you just need to use it like a property this.count this will run it and cache the result and return you.

if you want this to be a function then you need to define it in methods.

Thank you very much for your advice. The problem has been solved