From the course: Vue.js 2 Essential Training

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Using computed properties

Using computed properties

From the course: Vue.js 2 Essential Training

Start my 1-month free trial

Using computed properties

- Computer properties are a way to make simple transformations reusable. Plus, to have an advantage of also caching, so that updates to your interface are going to be really fast. Now, let's use this to create a slug for something we are typing in here. So slug is sort of a simplified version of a title. You see them when you go to websites, on the URLs generally, and the way that they work is special characters like this are not acceptable, everything's in lowercase and there are hyphens in between text characters. So, to do that, we could just add additional things here to this regular expression. So we can say slugText and then let's convert it to LowerCase here, right, and that will convert the text to lowercase, and then we can use the JavaScript replace command and that let's you use a regular expression, so this regular expression here is going to look for anything that is a simple word character and convert it and the g just means globally to just no characters. So it's just…

Contents