Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var app = new Vue({
- el: '#app-1',
- data: {
- heading: 'Daretron vol. 2',
- selected: 'Operacija',
- options: [{
- label: 'Operacija'
- },
- {
- label: '+',
- op: (a, b) => a + b
- }, {
- label: '-',
- op: (a, b) => a - b
- }, {
- label: '*',
- op: (a, b) => a * b
- }, {
- label: '/',
- op: (a, b) => a / b
- }],
- firstOperand: "",
- secondOperand: "",
- result: "",
- },
- methods: {
- operation: function() {
- var selectedOperation = this.options.find(item => item.label == this.selected)
- this.result = selectedOperation.op(parseFloat(this.firstOperand), parseFloat(this.secondOperand))
- this.firstOperand = ""
- this.secondOperand = ""
- this.selected = "Operacija"
- }
- }
- })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement