This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type Fruit { | |
id: ID! | |
name: String! | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type Query { | |
singleFruit(id: ID!): Fruit | |
allFruits: [Fruit] | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
input CreateFruitInput { | |
name: String! | |
} | |
type Mutation { | |
createFruit(input: CreateFruitInput!): Fruit | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var store = { | |
counter: 0, | |
addOne () { | |
this.counter ++; | |
} | |
}; | |
var componentA = new Vue({ | |
data: { | |
counter: store.counter |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var persistentStore = { | |
state: JSON.parse(localStorage.getItem('persistent-state')), | |
save () { | |
localStorage.setItem('persistent-state', JSON.stringify(this.state)); | |
} | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div id="fruits"> | |
<ul> | |
<li v-for="fruit in fruits">{{fruit}}</li> | |
</ul> | |
</div> | |
<script> | |
var component = new Vue({ | |
el: '#fruits', | |
data: { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var component = new Vue({ | |
el: '#fruits', | |
template: '#fruits-template', | |
data: { | |
fruits: ['Apple', 'Mango', 'Banana'] | |
} | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var element = document.getElementById('fruits-template'); | |
element.parentNode.removeChild(element); | |
var template = element.innerHTML; | |
var component = new Vue({ | |
el: '#fruits', | |
template: template, | |
data: { | |
fruits: ['Apple', 'Mango', 'Banana'] | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{% include components/fruit.html %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div id="fruit-template" class="vue-template"> | |
<div class="fruit"> | |
<h3>{{fruitName}}</h3> | |
</div> | |
</div> | |
<script> | |
Vue.component('my-fruit', { | |
template: '#fruit-template', | |
props: ['fruit-name'] |