[Vuejs]-How to bind span in vue js?

0👍

Currently your method randomNumberCreate() would return a random number each time you call it, as expected. So you can´t reuse the returned number just with this method.

What you could do, and you already tried to do so, is to assign the returned number to a property. You did this here:

x: this.randomCreate()

Now you can reuse x in your component like this:

<span :id="x" name="number" style="font-weight:bold; font-size:2rem;">{{x}}</span>

In this case :id="x" will have the same random number as {{x}}.

Leave a comment