R
R
reinmaker902020-11-12 19:01:55
Vue.js
reinmaker90, 2020-11-12 19:01:55

Is it correct to use vue computed like this?

DD, tell me, please, I re-read a couple of articles on this property, I seem to understand the differences from methods, but still the question is,
there is a request to the openWeather service, the answer is stored in the weatherResult variable and then it is displayed like this

<span>{{Math.round(weatherResult.main.temp)}}°C</span><br>
        <span>{{weatherResult.weather[0].description}}</span><br>
        <img :src="`https://openweathermap.org/img/wn/${weatherResult.weather[0].icon}@2x.png`" alt="">
        <span>{{weatherResult.name}},{{weatherResult.sys.country}}</span>

did I understand correctly that I can store data from weatherResult in computed and display them in spans?
From what I read, I understood that computed is used to monitor data variables and props data, that is, when they change, the computed property is called, and the method will twitch constantly.
I apologize in advance for not being clear.)

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question