-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
53f161d
commit 802a141
Showing
18 changed files
with
199 additions
and
187 deletions.
There are no files selected for viewing
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
This file was deleted.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { createApp } from 'vue' | ||
//1. Create the app instance | ||
const app = createApp({ | ||
template: '<MyComponent />' | ||
}); | ||
|
||
//2. Define the component | ||
const MyComponent = { | ||
template: 'This is my global component' | ||
} | ||
|
||
//3. Register a component globally | ||
|
||
app.component('MyComponent', MyComponent) | ||
app.mount('#app') |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,28 @@ | ||
const Collection = { | ||
data() { | ||
return { | ||
import { createApp } from "vue"; | ||
|
||
export const Collection = { | ||
data() { | ||
return { | ||
collection: { | ||
title: 'Watch Moonknight', | ||
description: 'Log in to Disney+ and watch all the chapters', | ||
priority: '5' | ||
title: 'Watch Moonknight', | ||
description: 'Log in to Disney+ and watch all the chapters', | ||
priority: '5' | ||
} | ||
} | ||
}, | ||
template: ` | ||
<ul> | ||
<li v-for="(value, name) in collection" :key="name"> <2> | ||
{{name}}: {{value}} | ||
</li> | ||
</ul> | ||
`, | ||
} | ||
} | ||
}, | ||
template: ` | ||
<ul> | ||
<li v-for="(value, name) in collection" :key="name"> | ||
{{name}}: {{value}} | ||
</li> | ||
</ul> | ||
`, | ||
}; | ||
|
||
const app = createApp({ | ||
components: { Collection }, | ||
template: `<Collection />` | ||
}); | ||
|
||
|
||
export default app; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
export const ConditionalRender = { | ||
template: ` | ||
<div> | ||
<div>Visibility: {{isVisible}}</div> | ||
<div v-show="isVisible">I'm the text in toggle</div> | ||
<div v-if="isVisible">I'm the visible text</div> | ||
<div v-else-if="showSubtitle">I'm the subtitle text</div> | ||
<div v-else>I'm the replacement text</div> | ||
</div> | ||
`, | ||
data() { | ||
return { | ||
isVisible: false, | ||
showSubtitle: false, | ||
} | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// export const InputWithKey = { | ||
// template: `<input @keydown="onEnter" >`, | ||
// methods: { | ||
// onEnter(e: KeyboardEvent) { | ||
//if (e.keyCode === 13) { | ||
// console.log('User pressed Enter!') | ||
// } | ||
// } | ||
// } | ||
// } | ||
|
||
export const InputWithKeyEnter = { | ||
template: `<input @keydown.enter="onEnter" >`, | ||
methods: { | ||
onEnter() { | ||
console.log('User pressed Enter!') | ||
} | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,42 +1,42 @@ | ||
export const MemoedList = { | ||
template: ` | ||
<ul> | ||
<li | ||
v-for="image in images" | ||
:key="image.id" | ||
:style=" selected === image.id ? { border: '1px solid blue' } : {}" | ||
@click="selected = image.id" | ||
v-memo="[selected === image.id]" <1> | ||
> | ||
<img :src="image.url"> | ||
<div>{{image.title}}</h2> | ||
</li> | ||
</ul> | ||
`, | ||
<ul> | ||
<li | ||
v-for="image in images" | ||
:key="image.id" | ||
:style=" selected === image.id ? { border: '1px solid blue' } : {}" | ||
@click="selected = image.id" | ||
v-memo="[selected === image.id]" <1> | ||
> | ||
<img :src="image.url"> | ||
<div>{{image.title}}</h2> | ||
</li> | ||
</ul> | ||
`, | ||
data() { | ||
return { | ||
return { | ||
selected: null, | ||
images: [{ | ||
id: 1, | ||
title: 'Cute cat', | ||
url: | ||
id: 1, | ||
title: 'Cute cat', | ||
url: | ||
'https://res.cloudinary.com/mayashavin/image/upload/w_100,h_100,c_thumb/TheCute%20Cat', | ||
}, { | ||
id: 2, | ||
title: 'Cute cat no 2', | ||
url: | ||
id: 2, | ||
title: 'Cute cat no 2', | ||
url: | ||
'https://res.cloudinary.com/mayashavin/image/upload/w_100,h_100,c_thumb/cute_cat', | ||
}, { | ||
id: 3, | ||
title: 'Cute cat no 3', | ||
url: | ||
id: 3, | ||
title: 'Cute cat no 3', | ||
url: | ||
'https://res.cloudinary.com/mayashavin/image/upload/w_100,h_100,c_thumb/cat_me', | ||
}, { | ||
id: 4, | ||
title: 'Just a cat', | ||
url: | ||
id: 4, | ||
title: 'Just a cat', | ||
url: | ||
'https://res.cloudinary.com/mayashavin/image/upload/w_100,h_100,c_thumb/cat_1', | ||
}] | ||
} | ||
} | ||
} | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,25 @@ | ||
// import type { ComponentOptions } from 'vue'; | ||
type Data = { | ||
printMsg: string; | ||
} | ||
|
||
export const PrintMessage = { | ||
template: ` | ||
<button @click="printMessage">Click me</button> | ||
<button @click.stop="printMessage">Click me</button> | ||
`, | ||
methods: { | ||
printMessage(e: Event) { | ||
if (e) { | ||
e.stopPropagation() | ||
} | ||
|
||
console.log("Button is clicked!") | ||
} | ||
printMessage(/*e: Event*/) { | ||
// (this as ComponentOptions<Data>).printMsg = "Button is clicked!" | ||
// if (e) { | ||
// e.stopPropagation(); | ||
// } | ||
|
||
console.log("Button is clicked!"); | ||
}, | ||
}, | ||
} | ||
data(): Data { | ||
return { | ||
printMsg: "Nothing to print yet!", | ||
} | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,12 @@ | ||
export const WithVHtml = { | ||
template: ` | ||
<div v-html="innerContent" /> | ||
<div v-html="innerContent" /> | ||
`, | ||
data() { | ||
return { | ||
innerContent: ` | ||
<div>Hello</div> | ||
` | ||
} | ||
return { | ||
innerContent: ` | ||
<div>Hello</div> | ||
` | ||
} | ||
} | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
export const WithVOnce = { | ||
template: ` | ||
<div> | ||
<input v-model="name" placeholder="Enter your name" > | ||
</div> | ||
<div v-once>{{name}}</div> `, | ||
data() { | ||
return { | ||
name: 'Maya' | ||
} | ||
} | ||
} |
Oops, something went wrong.