Bo Andersen
I am a back-end web developer with a passion for open source technologies. I have been a PHP developer for many years, and also have experience with Java and Spring Framework. I currently work full time as a lead developer. Apart from that, I also spend time on making online courses, so be sure to check those out!
Posts by Bo Andersen
Building Vue.js Applications for Production
In this short post, I want to show you how to build the project for production. This involves hiding any development messages and warnings, and also minifying JavaScript. To make a build, simply run the below command, which is defined within the package.json file. npm run build When doing so, a production build of your… read more
Single File Components
Now that we have taken a look at the structure of the project, let’s talk more about the App.vue file. This file consists of a so-called single file component. We can see this on the file name, which has the vue extension. This is a convention for single file components. These files contain a template… read more
Understanding the Project Structure
Alright, so now that we have set up our project, let’s actually see what it looks like. First, let’s open up the “package.json” file, which describes the project’s dependencies. { “name”: “sample-project”, “description”: “A Vue.js project”, “version”: “1.0.0”, “author”: “Bo Andersen “, “private”: true, “scripts”: { “dev”: “cross-env NODE_ENV=development webpack-dev-server –open –hot”, “build”: “cross-env NODE_ENV=production… read more
Creating a Project with Vue CLI
Now that we have introduced the Vue CLI and its templates, let’s now go ahead and install the tool. Node.js is required for installing Vue CLI, which you can get at nodejs.org. We won’t need it because we will be using Node.js itself, though, but because we will be using its package manager, NPM. If… read more
Introduction to Vue CLI
Vue CLI is a simple tool for scaffolding Vue.js applications, i.e. setting up a basic development environment and project structure. When doing so, one must choose a template, and there are currently five different ones to choose from. First we have a webpack template, which includes a full setup with webpack and includes things such… read more
Using Vue Instance Lifecycle Hooks
We just took a closer look at a Vue instance’s lifecycle, including which hooks we have at our disposal. In this post, I want to show you how to actually use these lifecycle hooks for running custom code at certain stages of a Vue instance’s lifecycle. Below is a simple Vue instance with all of… read more
Vue Instance Lifecycle & Hooks
In the last couple of posts, you have actually seen a few examples of parts of the Vue instance lifecycle. I didn’t mention it at the time, but let’s now see how some of the things we learned fit into the bigger picture. Each time we create a Vue instance, there are a series of… read more
Destroying a Vue instance
In this short post, I want to show you how you can destroy a Vue instance. Usually you won’t need to do this yourself, though. When we get into talking about components, we will see that it is better to control the lifecycle of child components by using directives such as the v-if directive. That’s… read more
Using Inline Templates within Vue Instances
Now that we have seen how to dynamically mount Vue instances to HTML elements, let’s see how we can use inline templates. Until now, we have always added all of our HTML markup within the HTML section on JSFiddle. But you can, however, also add a Vue instance’s template within the instance itself by using… read more
Mounting Vue.js Templates Dynamically
Until now, we have always used the el property within our Vue instances to specify which HTML element our Vue instance should control. Or, more formally, which element the Vue instance should be mounted to. This means that we have to know which element the Vue instance should be mounted to when we declare the… read more