Vue spread an object as computed properties Vue spread an object as computed properties vue.js vue.js

Vue spread an object as computed properties


Computed values can return objects, they just need to be returned by the function. Let me know if this isn't what you intended and I'll see what I can do to help!

let vm = new Vue({  el : "#root",  data : {    current : 0,    arrs : [      {        color : "background-color: blue;",        text : "Dabodee Dabodai"      },      {        color : "background-color: red;",        text : "Angry"      },      {        color : "background-color: green;",        text : "See it works!"      }    ]  },  computed : {    currentObject : function() {      return this.arrs[this.current];    }  }});
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.17/vue.js"></script><div id="root">  <input type="number" v-model="current" min="0" max="2">  <p :style="currentObject.color">    {{ currentObject.text }}  </p></div>