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
610
Other Decks in Technology
See All in Technology
生成AI時代のPythonセキュリティとガバナンス
abenben
0
120
FinOps について (ちょっと) 本気出して考えてみた
skmkzyk
0
210
難しいセキュリティ用語をわかりやすくしてみた
yuta3110
0
380
だいたい分かった気になる 『SREの知識地図』 / introduction-to-sre-knowledge-map-book
katsuhisa91
PRO
3
1.3k
「タコピーの原罪」から学ぶ間違った”支援” / the bad support of Takopii
piyonakajima
0
130
AIエージェント入門 〜基礎からMCP・A2Aまで〜
shukob
1
170
オブザーバビリティと育てた ID管理・認証認可基盤の歩み / The Journey of an ID Management, Authentication, and Authorization Platform Nurtured with Observability
kaminashi
1
140
AWS UG Grantでグローバル20名に選出されてre:Inventに行く話と、マルチクラウドセキュリティの教科書を執筆した話 / The Story of Being Selected for the AWS UG Grant to Attending re:Invent, and Writing a Multi-Cloud Security Textbook
yuj1osm
1
130
Implementing and Evaluating a High-Level Language with WasmGC and the Wasm Component Model: Scala’s Case
tanishiking
0
170
Observability for the system understanding and curious by developers
maruloop
1
230
JSConf JPのwebsiteをGatsbyからNext.jsに移行した話 - Next.jsの多言語静的サイトと課題
leko
2
180
AI時代、“平均値”ではいられない
uhyo
8
2.4k
Featured
See All Featured
Building a Scalable Design System with Sketch
lauravandoore
463
33k
A Modern Web Designer's Workflow
chriscoyier
697
190k
個人開発の失敗を避けるイケてる考え方 / tips for indie hackers
panda_program
116
20k
Automating Front-end Workflow
addyosmani
1371
200k
The World Runs on Bad Software
bkeepers
PRO
72
11k
Thoughts on Productivity
jonyablonski
70
4.9k
A better future with KSS
kneath
239
18k
[RailsConf 2023] Rails as a piece of cake
palkan
57
5.9k
Building a Modern Day E-commerce SEO Strategy
aleyda
44
7.8k
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
234
17k
GraphQLの誤解/rethinking-graphql
sonatard
73
11k
The Art of Programming - Codeland 2020
erikaheidi
56
14k
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