-
Notifications
You must be signed in to change notification settings - Fork 370
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
rush
committed
Feb 23, 2023
1 parent
f66176f
commit 579cd71
Showing
2 changed files
with
9 additions
and
28 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,45 +1,26 @@ | ||
<script type="module"> | ||
import { createApp } from '../src' | ||
|
||
|
||
// Custom Elements | ||
export class MyCounter extends HTMLElement { | ||
data() { | ||
return { | ||
$template: `<template>My count is {{ count }}<button @click="inc">++</button></template>`, | ||
count: 0, | ||
inc() { | ||
this.count++ | ||
} | ||
} | ||
} | ||
|
||
connectedCallback() { | ||
this.setAttribute('v-scope', "$el.data()") | ||
this.innerHTML = ` | ||
<style> | ||
* { | ||
font-size: 100%; | ||
} | ||
span { | ||
width: 4rem; | ||
display: inline-block; | ||
text-align: center; | ||
} | ||
button { | ||
width: 4rem; | ||
height: 4rem; | ||
border: none; | ||
border-radius: 10px; | ||
background-color: seagreen; | ||
color: white; | ||
} | ||
</style> | ||
<button @click="count--">-</button> | ||
<span v-text="count"></span> | ||
<button @click="count++">+</button> | ||
` | ||
createApp().mount(this) | ||
} | ||
} | ||
|
||
customElements.define("my-counter", MyCounter) | ||
createApp().mount() | ||
</script> | ||
|
||
<my-counter /> | ||
<my-counter count="hello"></my-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