Paul Melero
Web Developer
πIntroduction to Vue.js with Nuxt.js π
π₯
Did you install the dependencies?
npm i
Paul Melero
Front End Developer
Github | gangsthub |
---|---|
@paul_melero | |
CodeSandBox | gangsthub/sandboxes |
Erni | paul.melero@erni-espana.es |
We have better performance.
Gregg Pollack (Vue Mastery) and Evan You (Creator)
Not mandatory API, tho
Β
*html
*js/*ts
*(s)css
isolated
DOM node
or custom element
Shadow
DOM
CSS
Image from docs
<div id="simplest-example">
<h1>{{ whatever }}</h1>
</div>
new Vue({
Β el: '#simplest-example',
Β data: {
Β Β whatever: 'Hello world',
Β }
})
1
2
3
...
1
2
3
4
5
npm install --global vue-cli
>
<div id="app">
<span
v-if="seen"
>Now you see me</span>
</div>
new Vue({
el: '#app',
data: {
seen: true // <----
}
});
v-if
<div id="app">
<ol>
<li v-for="todo in todos">
{{ todo.text }}
</li>
</ol>
</div>
new Vue({
el: '#app',
data: {
todos: [ // <----
{ text: 'Learn JavaScript' },
{ text: 'Learn Vue' },
{ text: 'Build something awesome' }
]
}
})
Loopsβ
v-for (in)
<!-- method handler -->
<button v-on:click="doThis"></button>
<!-- inline statement -->
<button v-on:click="doThat('hello', $event)"></button>
<!-- shorthand -->
<button @click="doThis"></button>
<!-- key modifier using keyAlias -->
<input @keyup.enter="onEnter">
new Vue({
el: '#app',
// data: {},
methods: { // <----
doThat: function(...args) { /* ... */ }
}
})
<div id="app-6">
<p>{{ message }}</p>
<input v-model="message">
</div>
new Vue({
el: '#app',
data: {
message: 'How vuetiful is that!'
}
})
<div id="app-6">
<p>{{ message }}</p>
<p>{{ message.split('').reverse().join('') }}</p>
</div>
new Vue({
el: '#app',
data: {
message: 'I\'m the original message'
},
})
<p>{{ reversedMessage }}</p>
computed: {
reversedMessage: function () {
return this.message.split('').reverse().join('')
}
}
import Vue from 'vue';
import App from './app';
import router from '@router';
import store from '@state/store';
import 'components/globals.js';
const app = new Vue({
router,
store,
render: h => h(App),
}).$mount('#app')
Global vs Local
Image from docs
import ComponentA from './ComponentA.vue' export default {
name: 'parent-component',
data() {/* ... */}, Β methods: {/* ... */}, components: { ComponentA }, };
Vue.component('my-component', {
Β data() {/* ... */},
Β methods: {/* ... */},
Β // ...
});
// ES6 modules
By Paul Melero
The exercises that goes with the talk: https://github.com/gangsthub/vue-exercises