Home > Blockchain >  Vue Computed Component Not Firing
Vue Computed Component Not Firing

Time:09-20

I've been running the Vue extension for Chrome. As soon as I turned it off, none of my computed components work. All of my data comes from Django. One example:

import axios from 'axios'
    

export default { 
    name: 'Game',
    
    data() { 
        return { 
            game: {},
            newDate: ''
        }
    },

    computed: {
        dateNoTime() { 
                    this.newDate = this.game.date.substring(0, this.game.date.indexOf("T"));
        }

If I have the Vue extension loaded, using {{ newDate }} works just fine. Without it, however, nothing gets pulled. I've tried a method as well with no luck.

CodePudding user response:

this one worked when I tested it

methods: {
  dateNoTime: function () { 
    this.newDate = this.game.date.toJSON().slice(0,10).replace(/-/g,'/');
  }
},
  mounted () {
  this.dateNoTime()
}

CodePudding user response:

First of all computed property has to return some value. Please refer to official Vue documentation. https://vuejs.org/guide/essentials/computed.html#basic-example

  • Related