[Vuejs]-Save input and give output in VueJs

0👍

You have to duplicate your object, one containing the current state the other one the new state. When pushing the button, you update the current state.

export default {
  name: "Measurements",
  created() {
    this.newState = JSON.parse(JSON.stringify(this.currentState));
  },
  data () {
    return {
      currentState: { },
      newState: {}
    };
  },
  methods: {
    addItems() {
      this.currentState= JSON.parse(JSON.stringify(this.newState));
    }
  }
};

0👍

Just add a new variable to determine the visible/hidden state of your input. You can do so by adding a v-if to your html element and adjusting your addItems method just like that.

  data: () => {
    return {
       ...
       showHeight: false,
       ...
    };
  },
  methods: {
      addItems() {
        this.showHeight = true;
      }
  }

Leave a comment