Capture values followed by a textarea in the same function

Asked

Viewed 47 times

1

I’m developing a console with HTML5 + Vue to streamline some simple commands.

The inserted command comes through a textarea with v-model="cmd" v-on:keyup.enter="consoleMode()".

I’m using Else if even, since I only need a 4 functions.

consoleMode: function(cmd){
  this.cmdHistory.push({command: this.cmd})
  if(this.cmd == 'cls\n'){
    this.cmdHistory = [{command: 'início'}]
  } else if(this.cmd == 'add client\n'){
    this.cmdQuest = 'Qual o nome do cliente?'
    //ler a primeira resposta e fazer outras perguntas
  } else if(this.cmd == 'exit\n'){
    this.cmdQuest = ''
  }
  this.cmd = ''
}

I stalled on the first question because I have no idea how to capture some values in style scanf in C with this textarea.

Basically, I need that if it captures 4 values in a row (one by one, always cleaning the textarea) and throw in an object newClient, alternating the value of this.cmdQuest for each new line("What’s the name?" "What’s the number?" etc.).

If there are any plugin to help in this, it would be nice.

EDIT1: the this.cmdHistory is an array with objects like {command: 'my last command'} http://prntscr.com/g406fv

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.