Skip to Content
Vue.js 2 Cookbook
book

Vue.js 2 Cookbook

by Andrea Passaglia
April 2017
Intermediate to advanced
454 pages
12h 51m
English
Packt Publishing
Content preview from Vue.js 2 Cookbook

How to do it...

Let's say we are curating an interactive page to learn history. We have our Vue instance with the following JavaScript code:

new Vue({   el:'#app',   data: {     bastilleStormingDate: '1789-07-14 17 h'   } })

In our data, we have a date written informally as a string in our instance data. Our HTML can contain a timeline of the French Revolution and, at some point, can contain the following:

<div id="app">   The Storming of the Bastille, happened on {{bastilleStormingDate | date}} </div>

We need a filter capable of completing the sentence. For this, one possible library is the excellent moment.js and, for our purposes, we'll choose the localized version: https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.14.1/moment-with-locales.js ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Learning Vue.js 2

Learning Vue.js 2

Olga Filipova
Pro Vue.js 2

Pro Vue.js 2

Adam Freeman

Publisher Resources

ISBN: 9781786468093Supplemental Content