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
Vue.js__1_.pdf
Search
Christian Nascimento
September 24, 2016
Technology
2
160
Vue.js__1_.pdf
Christian Nascimento
September 24, 2016
Tweet
Share
More Decks by Christian Nascimento
See All by Christian Nascimento
O que é vuex e para que ele serve
cnascimentord
0
590
Other Decks in Technology
See All in Technology
LLM とプロンプトエンジニアリング/チューターをビルドする / LLM and Prompt Engineering and Building Tutors
ks91
PRO
0
220
反実仮想機械学習とは何か
usaito
PRO
6
1.6k
**強い**エンジニアのなり方 - フィードバックサイクルを勝ち取る / grow one day each day
soudai
60
17k
Hands-on / Kaname Frusawa / Cloud Compare Users Meetup 2024 at University of Tokyo on April 17
paraworld
2
470
コードを書く隙間を見つけて生きていく技術/Findy 思考の現在地
fujiwara3
24
4.9k
AIQ株式会社 エンジニア向け会社紹介資料
aiqlab
0
360
〜小さく始めて大きく育てる〜データ分析基盤の開発から活用まで
kniino
0
2k
Algyan イベント振り返り
linyixian
0
180
普段有償でサポート業務をしているCSAが技術知見を無料で公開する理由
07jp27
1
630
TransitGatewayの基礎
toru_kubota
0
230
開発生産性向上サービスを作るFindyが自分たちで開発生産性を爆上げした組織づくりの歩み / Findy's path to boosting its own development productivity 2024-04-17
ma3tk
1
290
株式会社EventHub・エンジニア採用資料
eventhub
0
1.9k
Featured
See All Featured
For a Future-Friendly Web
brad_frost
171
8.9k
Build The Right Thing And Hit Your Dates
maggiecrowley
23
2k
Imperfection Machines: The Place of Print at Facebook
scottboms
258
12k
A Tale of Four Properties
chriscoyier
150
22k
The Mythical Team-Month
searls
214
42k
Designing on Purpose - Digital PM Summit 2013
jponch
110
6.4k
Why You Should Never Use an ORM
jnunemaker
PRO
50
8.6k
Fontdeck: Realign not Redesign
paulrobertlloyd
75
4.9k
Web Components: a chance to create the future
zenorocha
304
41k
CoffeeScript is Beautiful & I Never Want to Write Plain JavaScript Again
sstephenson
153
14k
Code Reviewing Like a Champion
maltzj
513
39k
Java REST API Framework Comparison - PWX 2021
mraible
PRO
18
6.9k
Transcript
Vue.js: Uma alternativa ao Angular.js, Ember.js e React.js
Christian Nascimento Resultados Digitais @cnascimentobr
Vue (pronounced /vjuː/, like view)
Evan You Ex Google e Meteor Core Dev @youyuxi
Vue.js é uma biblioteca javascript para o desenvolvimento de componentes
reativos para interfaces web modernas.
Componentes
APP SIDEBAR ITEM CONTENT
var Example = Vue.extend({ template: '<div>{{ message }}</div>', data: function
() { return { message: 'Hello Vue.js!' } } }) // register it with the tag <example> Vue.component('example', Example)
<example></example> http://vuejs.org/guide/components.html
? Reativo
None
Manter as alterações de seus objetos em sincronia com a
view é difícil?
var object = { message: 'Hello world!' }
<div id="example"> {{ message }} </div>
new Vue({ el: '#example', data: object }) Mais o mais
importante ...
setTimeout(function() { scope.$apply(function() { scope.someVal = 123 }); }, 1000);
setState(function(previousState, currentProps) { return { myInteger: previousState.myInteger + 1 };
});
user = Ember.Object.create({ firstName: 'Sam', lastName: 'Smith' }) user.get('firstName') is
'Sam' #=> true user.get('lastName') is 'Smith' #=> true
None
Moderno
// React.js (jsx) var Component = React.createClass({ getInitialState() { return
{ object: this.props.object } },...
// Vue.js var Component = Vue.component('component', { template: '<span>{{object.title}}</span>', props:
{ object: Object } });...
// Angular 2 import { Component } from '@angular/core'; @Component({
selector: 'my-component', template: '<div>Hello my name is {{name}}. <button (click)="sayMyName()">Say my name</button></div>' }) export class MyComponent { constructor() { this.name = 'Max'...
None
https://webpack.github.io/ http://browserify.org/ Vue-cli: https://github.com/vuejs/vue-cli
Sintaxe e API
None
<div id="app"> <input v-model="newTodo" v-on:keyup.enter="addTodo"> <ul> <li v-for="todo in todos">
<span>{{ todo.text }}</span> <button v-on:click="removeTodo($index)">X</button> ...
new Vue({ el: '#app', data: { newTodo: '', todos: [
{ text: 'Add some todos' } ] }, ...
methods: { addTodo: function () { var text = this.newTodo.trim()
if (text) { this.todos.push({ text: text }) this.newTodo = '' } },... http://vuejs.org/api/
Flexibilidade
// Vue Router import Vue from 'vue'; import VueRouter from
'vue-router'; import config from 'config'; Vue.use(VueRouter) const router = new VueRouter({history: true, root: config.root}); router.map({ '/': { name: 'home', component: view('home') }, });
// Vue Resource this.$http.get('api/events').success(function(events ) { this.$set('events', events); }).error(function(error) {
console.log(error); });
Performance
https://github.com/mathieuancelin/js-repaint-perfs
http://tinyurl.com/z7uba8n
Pronto para usar
None
None
Futuro
Vue.js 2.0 Virtual DOM + SSR http://rc.vuejs.org/guide/
// JSX new Vue({ el: '#app', methods: { hello ()
{ alert('Hello!') } }, render (h) { return ( <h1 on-click={this.hello}>Hello from JSX</h1> ) ...
None
None
Recursos https://github.com/vuejs/awesome-vue http://www.vuejs-brasil.com.br/ https://codecasts.com.br/lesson https://laracasts.com/ https://www.schoolofnet.com/ https://leanpub.com/vue
Exemplo todovue.herokuapp.com
Rails 5 API
// todobe/app/controllers/api/v1/todos_controller.rb module Api::V1 class TodosController < ApiController include ErrorSerializer
before_action :set_todo, only: [:show, :update, :destroy] def index @todos = Todo.all render json: @todos end ...
// todobe/app/serializers/todo_serializer.rb class TodoSerializer < ActiveModel::Serializer attributes :id, :title, :completed,
:order end
// todobe/config/initializers/active_model_serializer.rb ActiveModel::Serializer.config.adapter = ActiveModelSerializers::Adapter::JsonApi
// JSON { "data": [ { "id": "6", "type": "todos",
"attributes": { "title": "casadasd", "completed": false, "order": 2 ...
Vue.js app
// Main.js import Vue from 'vue'; import App from './App';
import VueSweetAlert from 'vue-sweetalert' ; require('font-awesome/css/font-awesome.css' ); Vue.use(require( 'vue-resource' )); Vue.use(VueSweetAlert); new Vue({ el: 'body', components: { App }, });
// App.vue <template> <div id="app"> <img class="logo" src="./assets/logo.png" > <todo></todo>
</div> </template> <script> import Todo from './components/Todo' ; ...
// Todo.vue ... <button v-on:click="addTodo" class="form-control" >Submit</button> <ul class="list-group" v-if="todos.length
> 0" > <li v-for="todo in todos | orderBy 'attributes.order'" track-by="$index" class="list-group-item" > <todo-item :todolist ="todo"></todo-item> </li> </ul> </div> ...
// TodoItem.vue import { API_BASE_URL } from '../../config/index.js' ; export
default { props: ['todolist','fetchtodos' ], data() { return { isEditing: false, newTitle: '', }; }, methods: { editTodo() { this. $set('isEditing', true); },...
Obrigado! Christian Nascimento @cnascimentobr
[email protected]
shipit.resultadosdigitais.com.br we’re hiring