Vue simple calculator component

Create a simple Vue calculator

Even though Vue.js is capabilities are endless, the framework can not only be used for complex tasks. One of the features of Vue is its simplicity. And that means that it is perfect for smaller tasks. One of the functionalities you might have on your website, might be a calculator. For this purpose you can use a Vue simple calculator component – vue-webpack-calculator.

Check on GitHub

How to install simple Vue calculator

If you are willing to try the vue-webpack-calculator component, you can do so by cloning tit from the GitHub repository:

git clone

After that, change the directory to the folder with code of cloned repository:

cd simply-calculator-vuejs

The following step would be to install the needed dependencies. And this could be done with npm:

npm install

Everything should go fluently, and as a result, you will be able to start the local server with a component loaded. By default it will be served as http://localhost:8080:

npm run dev
Simple Vue calculator was served successfully

Optionally you can build this for production. Following command will execute code mimification:

npm run build

Implementing calculator component into your application

That’s it, now you have a simple component that is capable of doing basic math operations. You might incorporate it into your other functionality. For example, you might create this code chunk into your App.vue file:

  <div id="calculator">
      <span class="author">BY <a href="" target="_blank">CaiYiLiang</a></span>
    <section class="calculator" id="calculator">

import CalculatorContent from 'components/CalculatorContent.vue'
export default {
  name: 'calculator',
  components: {



@import url('');

   font-size:62.5%;  /* =10px */

  background-color:#f4f1f1; /* HEX */

  font-size: 1.8rem;
  font-family: 'Pacifico', cursive;

header .author{
  font-size: 1.5rem;

header .author a{
  text-decoration: none;

header , .calculator {
  margin: 2.5rem auto;
  text-align: center;

  border: 0.8rem solid #f67373;
  width: 34rem;
  height: 40rem;
  background-color: #f28080;
  font-size: 1.6rem;
  -webkit-border-radius: 1rem;
  -moz-border-radius: 1rem;
  -ms-border-radius: 1rem;
  -o-border-radius: 1rem;
  border-radius: 1rem;: 
  -webkit-box-shadow: 1rem 1rem 0.5rem #ccc;
  box-shadow: 1rem 1rem 0.5rem #ccc;


And in your main.js script, you might define it like this:

import Vue from 'vue'
import Calculator from './Calculator.vue'

new Vue({
  el: '#calculator',
  render: h => h(Calculator)