Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Vuejs
Search
Thulio Philipe
March 18, 2017
Programming
5
970
Vuejs
Talk realizada no Front in Maceió 2017 sobre o Vuejs.
Thulio Philipe
March 18, 2017
Tweet
Share
More Decks by Thulio Philipe
See All by Thulio Philipe
CUI & Feature Flags
thulioph
0
17
+97% of Time Reduction to Onboarding New Metrics
thulioph
0
96
Cache, além do CTRL + F5
thulioph
0
74
CSS na era dos Componentes
thulioph
0
350
Recompose
thulioph
1
500
Styled Components
thulioph
0
360
Redux 101
thulioph
0
220
Cache
thulioph
2
230
Segurança de Aplicações Web - 101
thulioph
0
120
Other Decks in Programming
See All in Programming
良いユニットテストを書こう
mototakatsu
5
1.9k
ゆるやかにgolangci-lintのルールを強くする / Kyoto.go #56
utgwkk
1
360
競技プログラミングへのお誘い@阪大BOOSTセミナー
kotamanegi
0
350
rails stats で紐解く ANDPAD のイマを支える技術たち
andpad
1
290
The Efficiency Paradox and How to Save Yourself and the World
hollycummins
1
440
快速入門可觀測性
blueswen
0
330
17年周年のWebアプリケーションにTanStack Queryを導入する / Implementing TanStack Query in a 17th Anniversary Web Application
saitolume
0
250
The rollercoaster of releasing an Android, iOS, and macOS app with Kotlin Multiplatform | droidcon Italy
prof18
0
150
Fibonacci Function Gallery - Part 1
philipschwarz
PRO
0
210
ブラウザ単体でmp4書き出すまで - muddy-web - 2024-12
yue4u
2
460
今からはじめるAndroidアプリ開発 2024 / DevFest 2024
star_zero
0
1k
Cloudflare MCP ServerでClaude Desktop からWeb APIを構築
kutakutat
1
530
Featured
See All Featured
Become a Pro
speakerdeck
PRO
26
5k
Code Review Best Practice
trishagee
65
17k
The Cult of Friendly URLs
andyhume
78
6.1k
BBQ
matthewcrist
85
9.4k
How to Think Like a Performance Engineer
csswizardry
22
1.2k
Fashionably flexible responsive web design (full day workshop)
malarkey
405
66k
Music & Morning Musume
bryan
46
6.2k
It's Worth the Effort
3n
183
28k
Into the Great Unknown - MozCon
thekraken
33
1.5k
Thoughts on Productivity
jonyablonski
67
4.4k
The Straight Up "How To Draw Better" Workshop
denniskardys
232
140k
Distributed Sagas: A Protocol for Coordinating Microservices
caitiem20
330
21k
Transcript
Vue.js Thulio Philipe @thulioph Web Developer
Viu-Djêi-Éss (vuejs)
Thulio Philipe @thulioph Web Developer @labcodes Web Apps @unibratec Team
@devbeers " ⚙
Thulio Philipe @thulioph_ Web Developer @labcodes Web Apps @unibratec Team
@devbeers " ⚙
Atenção!
• O slides serão disponibilizados. Atenção!
• O slides serão disponibilizados. • Não se preocupe com
links, todos estão nos slides. Atenção!
• O slides serão disponibilizados. • Não se preocupe com
links, todos estão nos slides. • Tome nota de alguns termos, pode ser útil para uma pesquisa futura. Atenção!
• O slides serão disponibilizados. • Não se preocupe com
links, todos estão nos slides. • Tome nota de alguns termos, pode ser útil para uma pesquisa futura. • Esta palestra pode conter imagens de gatos. Atenção!
Conceitos
goo.gl/cgbP0l Components
components
components
Stateful goo.gl/knaTae
const hour = 1; const increment = () => hour
+ 1; increment(); // 2
goo.gl/knaTae Stateless
const hour = 1; const increment = (a) => a
+ 1; increment(hour);
Web components webcomponents.org
Uma coleção de web apis que permitem você criar novas
tags HTML reusaveis e totalmente customizadas.
Uma coleção de web apis que permitem você criar novas
tags HTML reusaveis e totalmente customizadas
1. Custom Elements 2. HTML imports 3. HTML Template 4.
Shadow DOM
1. Custom Elements 2. HTML imports 3. HTML Template 4.
Shadow DOM
Especificação que permite utilizar novos tipos de elementos DOM custom
elements
Define como você encapsula estilo e marcação no componente shadow
DOM
Webpack webpack.js.org
import bar from './bar'; bar(); app.js
export default function bar() { console.log('Hi, bar'); } bar.js
module.exports = { entry: './app.js', output: { filename: 'bundle.js' }
} webpack.config.js
<html> <head> ... </head> <body> ... <script src="bundle.js"></script> </body> </html>
index.html
Você sabia?
None
None
U$ 65.4 bilhões de dólares
None
• Huguinho • O líder
• Huguinho • O líder
• Zezinho • O mais esperto
• Zezinho • O mais esperto
• Luizinho • O mais criativo
• Luizinho • O mais criativo
Vuejs github.com/vuejs
Evan You @yyx990803 github.com/open-source/stories/yyx990803
github.com/vuejs/vue/pulse 46,148 5,938 194
Hello World
CDN vuejs.org/v2/guide
<html> <head> ... </head> <body> <div id="app"> {{ message }}
</div> <script src="https://unpkg.com/vue"></script> <script src="app.js"></script> </body> </html> index.html
new Vue({ el: '#app', data: { message: 'Hello Vue!' }
}); app.js
<html> <head> ... </head> <body> <div id="app"> Hello Vue! </div>
<script src="https://unpkg.com/vue"></script> <script src="app.js"></script> </body> </html> index.html
Vue-CLI github.com/vuejs/vue-cli
$ npm install -g vue-cli $ vue init webpack my-project
$ npm install -g vue-cli $ vue init webpack my-project
template nome do projeto
• ES2015+ • Webpack + vue-loader (.vue) • Testes •
e2e • Nightwatch • Unitários • Karma • Mocha + Chai + Sinon • Vue router • ESLint • PostCSS
Components
vuejs.org/v2/guide Estrutura [componentes globais]
Vue.component(tagName, options);
Vue.component('my-component', { template: '<h1>Hello World!</h1>' //options }); new Vue({ el:
'#app' });
<div id="app"> <my-component></my-component> </div>
<div id="app"> <h1>Hello World!</h1> </div>
vuejs.org/v2/guide Estrutura [single-file component]
<template> // marcação </template> <script> // comportamento </script> <style> //
estilo </style>
<template> <h1>{{ message }}</h1> </template> <script> export default { name:
'app', data() { return { message: 'Hello World' } } }; </script> <style></style>
Data vuejs.org/v2/guide
<template> <h1> {{ title }} </h1> </template>
export default { name: 'Título', data() { return { title:'Título
Aqui' } } }
<template> <h1> Título Aqui </h1> </template>
vuejs.org/v2/guide Lifecycle [hooks]
lifecycle
lifecycle
lifecycle
export default { name: 'Meu Componente', created() { console.warn('Created'); },
mounted() { console.warn('Mounted'); }, updated() { console.warn('Updated'); }, destroyed() { console.warn('Destroyed'); } }
Props vuejs.org/v2/guide
<my-contact :address="Rua deserto do Atacama"> </my-contact>
export default { name: 'Contato', props: ['address'] }
<p>{{ address }}</p>
<p>Rua deserto do Atacama</p>
Methods vuejs.org/v2/guide
<template> <button @click="toggle"> Mudar Status </button> <p>{{ active }}</p> </template>
export default { name: 'Toggle botão', methods: { toggle() {
this.active = !this.active; } }, data() { return { active: false } } }
Diretivas vuejs.org/v2/guide
• v-model • v-on • v-on:click="doSomething" • @click="doSomething" • v-bind
• :href="url", :class="myClass" • v-for • v-show • v-if
vuejs.org/v2/guide Modifiers
<form @submit.prevent="onSubmit"> </form>
Rotas
vue-router router.vuejs.org
$ npm install vue-router --save
index.html <body> ... <router-view></router-view> <script src="https://unpkg.com/ vue-router"> </script> </body>
import Foo from './components/Foo.vue' import Bar from './components/Bar.vue' export default
= [ { path: '/foo', component: Foo }, { path: '/bar', component: Bar } ] routes.js
import Vue from 'vue' import VueRouter from 'vue-router' import routes
from './routes' Vue.use(VueRouter); const router = new VueRouter({ routes }); export default router; index.js
import Vue from 'vue' import router from './index' new Vue({
el:'#app', router }); main.js
Gerenciando estados
vuex vuex.vuejs.org
$ npm install vuex --save
<body> ... <script src="https://unpkg.com/vuex"> </script> </body> index.html
vuex
Testes
vuejs.org/v2/guide Teste unitário
None
MyComponent .vue
<template> <span>{{ message }}</span> </template>
export default { data () { return { message: 'Hello!'
} }, created () { this.message = 'Bye!' } }
MyComponent .test.js
import Vue from 'vue' import MyComponent from 'path/to/ MyComponent.vue'
describe('MyComponent Spec', () => { it('Sets the correct default data',
() => { const defaultData = MyComponent.data(); expect(defaultData.message).toBe('Hello!'); }); });
github.com/vuejs-templates Teste e2e
None
MyComponent .vue
<template> <div id="app"> <h1>{{message}}</h1> </div> </template> <script> export default {
name: 'meu app', data() { return { message: 'Olá mundo!', }; } }; </script>
MyComponent .test.js
const devServer = browser.globals.devServerURL; browser .url(devServer) .waitForElementVisible('#app', 5000) .assert.containsText('h1', 'Olá
mundo!') .end();
Mobile e Desktop
Framework 7 framework7.io
github.com/nolimits4web/framework7 9,107 1,981 58
Onsen UI onsen.io
github.com/OnsenUI/OnsenUI 4,406 575 92
VOnic github.com/wangdahoo/vonic
github.com/wangdahoo/vonic 1,542 214 8
Comunidade
i18n
Debug github.com/vuejs/vue-devtools
Github github.com/vuejs/awesome-vue
Slack slack.vuejs-brasil.com.br
E-mail vuejsfeed.com
Fórum forum.vuejs.org
Artigos vuejs-brasil.com.br
Demo
• Vuejs • @2.0 • Travis • Karma + Jasmine
• Leaflet • Mapa • Firebase • database • auth • Bulma • Heroku
goo.gl/dgqlZ1
None
Thulio Philipe @thulioph Web Developer goo.gl/idCGmm Obrigado!