Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the main difference between computed and mounted in vue.js 2?

Tags:

vue.js

vuejs2

when i add computed() instead mounted() it throws an error

export default {
  components: {
    MainLayout
  },
  mounted(){
    var x = document.getElementById('homeTabPanes');
    // x.style.background = "blue";
    console.log("check the value of x", x);
  }
}
like image 325
Adarsha Jha Avatar asked Oct 15 '25 20:10

Adarsha Jha


1 Answers

computed is an object containing methods that returns data, mounted is a life hook executed after the instance gets mounted, check out the links to the docs it have really good explanation

like image 170
Mohd_PH Avatar answered Oct 18 '25 23:10

Mohd_PH



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!