JavaScript Calculating numbers with vue calculating numbers with powers,calculating numbers with exponents,calculating numbers

I am really new to vueJS.

I try to get two input value, adding them together, and show the result. I found it is really wired, because when number1 minus number3, or number1 multiplied number2, or number1 divided number2, the calculating is all working fine. However when number1 plus number2, it doesn’t working, and seems add two str together (for example: 1 + 2 = 12).

What’s going on here? And how can I get result with number1 + number2

Please help

<div id="app">

        <input type="number" name="number1" v-on:input= "update_number1">
        <p>{{ number1 }}</p>
        <input type="number" name="number2" v-on:input= "update_number2">
        <p>{{ number2 }}</p>

        <hr>
        <p>{{ result() }}</p>

</div>

new Vue({
  el: '#app',
  data: {
    number1: 0,
    number2: 0,
  },
  methods: {
    update_number1: function (event) {
      this.number1 = event.target.value;
    },
    update_number2: function (event) {
      this.number2 = event.target.value;
    },
    result: function () {

      return this.number1 + this.number2;
    },

  },
});
Answer:1

This is more likely a javascript problem than a vue one.

If you want to add two numbers, you can use parseInt() function as:

result: function () {
  return parseInt(this.number1) + parseInt(this.number2);
}
Answer:2

I need your help, While the code below works great to dynamically switch my div content, the problem now is that the javascript code does not hide the user's previous selection. Any ideas on how to ...

I need your help, While the code below works great to dynamically switch my div content, the problem now is that the javascript code does not hide the user's previous selection. Any ideas on how to ...

  1. jquery show hide dynamic content

I have solved the seventh problem of Euler, it says: By listing the first six prime numbers: 2, 3, 5, 7, 11, and 13, we can see that the 6th prime is 13. What is the 10 001st prime number? ...

I have solved the seventh problem of Euler, it says: By listing the first six prime numbers: 2, 3, 5, 7, 11, and 13, we can see that the 6th prime is 13. What is the 10 001st prime number? ...

I'm trying to use d3-arrays in a project. The module itself includes both original ES6 modules and a UMD build. I would expect to be able to add this directly as a dependency to my ember-cli project ...

I'm trying to use d3-arrays in a project. The module itself includes both original ES6 modules and a UMD build. I would expect to be able to add this directly as a dependency to my ember-cli project ...

  1. cannot import module python
  2. cannot import module in jupyter
  3. cannot import module python3
  4. cannot import module in same directory
  5. cannot import module '@nuxt/webpack'
  6. cannot import module '@nuxt/core'
  7. cannot import module in pycharm
  8. cannot import module js
  9. cannot import module in same directory python
  10. cannot import module activedirectory
  11. cannot import module
  12. cannot import module powershell
  13. cannot import module msonline
  14. cannot import module 'ts-node' nuxt
  15. cannot import module android studio
  16. cannot import module flask
  17. cannot import module django
  18. cannot import ad sync module
  19. cannot import module vmware.vimautomation.core
  20. cannot import module with spaces in tag ''

Here is my code <div class="EquipmentContent row"> <div class="col-xs-12 col-sm-6 col-md-6 col-lg-6 subSection" style="float:right;background:#dff0ff;"> <section ...

Here is my code <div class="EquipmentContent row"> <div class="col-xs-12 col-sm-6 col-md-6 col-lg-6 subSection" style="float:right;background:#dff0ff;"> <section ...

  1. dynamically append button