new Vue({});
new Vue({
});
el:
'#app'
new Vue({
el: '#app',
});
<body>
<div id="app"></div>
</body>
new Vue({
el: '#app',
});
data: {}
new Vue({
el: '#app',
data: {
speaker: 'Hassan Djirdeh',
workshop: 'A Full Day of Vue.js',
city: 'Toronto'
},
});
<div id="app">
<h1>The speaker is ...</h1>
<h1>The workshop is ...</h1>
<h1>The city is ...</h1>
</div>
main.js
index.html
{{Mustache}} syntax
new Vue({
el: '#app',
data: {
speaker: 'Hassan Djirdeh',
workshop: 'A Full Day of Vue.js',
city: 'Toronto'
},
});
<div id="app">
<h1>The speaker is {{speaker}}</h1>
<h1>The workshop is {{workshop}}</h1>
<h1>The city is {{city}}</h1>
</div>
main.js
index.html
Mustache Syntax
index.html
main.js
new Vue({
el: '#app',
data: {
speaker: 'Hassan Djirdeh',
img: 'https://avatars3.githubusercontent...',
workshop: 'A Full Day of Vue.js',
city: 'Salt Lake City'
},
});
<div id="app">
<h1>The speaker is {{speaker}}</h1>
<img src="img" />
<h1>The workshop is {{workshop}}</h1>
<h1>The city is {{city}}</h1>
</div>
new Vue({
el: '#app',
data: {
speaker: 'Hassan Djirdeh',
img: 'https://avatars3.githubusercontent...',
workshop: 'A Full Day of Vue.js',
city: 'Salt Lake City'
},
});
<div id="app">
<h1>The speaker is {{speaker}}</h1>
<img v-bind:src="img" />
<h1>The workshop is {{workshop}}</h1>
<h1>The city is {{city}}</h1>
</div>
main.js
index.html
v-bind
v-if/v-show
v-on
v-for
v-model
new Vue({
el: '#app',
data: {
speaker: 'Hassan Djirdeh',
img: 'https://avatars3.githubusercontent...',
workshop: 'Intro to Vue',
city: 'Salt Lake City'
},
});
<div id="app">
<h1>The speaker is {{speaker}}</h1>
<img v-bind:src="img" />
<h1>The workshop is {{workshop}}</h1>
<h1>The city is {{city}}</h1>
</div>
main.js
index.html
new Vue({
el: '#app',
data: {},
});
methods: {}
new Vue({
el: '#app',
data: {
speaker: 'Hassan Djirdeh',
...
},
methods: {
changeSpeaker() {
this.speaker = 'Aubrey Graham';
}
}
});
<div id="app">
<h1>The speaker is {{speaker}}</h1>
<img v-bind:src="img" />
<h1>The workshop is {{workshop}}</h1>
<h1>The city is {{city}}</h1>
<button v-on:click="changeSpeaker">
Change Speaker
</button>
</div>
main.js
index.html
const speakerElement = $('h1:first');
const imgElement = $('img');
('button').on({
'click': function() {
if (speakerElement.text() === 'Hassan Djirdeh') {
imgElement.attr('src','https://s3-us-west-2.amazonaws.com/...');
speakerElement.text('Aubrey Graham');
} else {
// ...
}
}
});
new Vue({
el: '#app',
data: {
speaker: 'Select a speaker!',
img: 'https://via.placeholder.com/350x150',
workshopDetails: null,
city: '',
},
methods: {
changeWeather() {
this.weather = 'sunny';
}
}
});
<h1 v-if="ok">Yes</h1>
<h1 v-show="ok">Yes</h1>
<h1 v-on:click="method">Yes</h1>
<h1 v-on:dblclick="method">Yes</h1>
<input v-on:keydown="method" />
<input v-on:keyup="method" />
<input v-on:submit="method" />
...
<input v-on:keyup.tab="method" />
...
<input v-on:keyup.enter="method" />
<input v-on:keyup.delete="method" />
<input v-on:keyup.escape="method" />
<input v-on:keyup.space="method" />
<h1 v-on:click="method">Yes</h1>
<h1 @click="method">Yes</h1>
<img v-bind:src="img"/>
<img :src="img"/>
const tweets = [
{
id: 1,
name: 'James',
handle: '@jokerjames',
img: 'https://semantic-ui.com/images/avatar2/large/matthew.png',
tweet: "If you don't succeed, dust yourself off and try again.",
likes: 10,
},
{
id: 2,
name: 'Fatima',
handle: '@fantasticfatima',
img: 'https://semantic-ui.com/images/avatar2/large/molly.png',
tweet: 'Better late than never but never late is better.',
likes: 12,
},
{
id: 3,
name: 'Xin',
handle: '@xeroxin',
img: 'https://semantic-ui.com/images/avatar2/large/elyse.png',
tweet: 'Beauty in the struggle, ugliness in the success.',
likes: 18,
}
];
new Vue({
el: '#app',
data: {
tweets
}
});
v-for="item in items"
<div id="app">
<div class="tweet" v-for="tweet in tweets">
// ...
</div>
</div>
v-for="tweet in tweets" :key="tweet.id"
tweets[0].name = 'Hassan Djirdeh'
tweets.length = 5
Vue.set(tweets, 0, {name: 'Hassan Djirdeh'...});
this.tweets.splice(5)
v-model="dataAttribute"
new Vue({
el: '#app',
data: {
name: '',
subject: '',
termsAndConditions: false,
yesOrNo: 'Yes'
},
});
v-bind:
v-on:
v-for:
v-model:
v-if/v-show: