example code using v-model and v-effect
This commit is contained in:
parent
ad1c48b7ed
commit
bba0177f9f
2 changed files with 19 additions and 5 deletions
|
@ -3,9 +3,15 @@ import { createApp } from './lib/petite-vue.es.js'
|
||||||
createApp({
|
createApp({
|
||||||
$delimiters: ['{|', '|}'],
|
$delimiters: ['{|', '|}'],
|
||||||
urlParams: new URL(location.href).searchParams,
|
urlParams: new URL(location.href).searchParams,
|
||||||
mydata: Data(),
|
newdata: '',
|
||||||
|
data: '',
|
||||||
|
save
|
||||||
}).mount()
|
}).mount()
|
||||||
|
|
||||||
|
function save() {
|
||||||
|
this.data += '\n' + this.newdata
|
||||||
|
}
|
||||||
|
|
||||||
function Data() {
|
function Data() {
|
||||||
return {
|
return {
|
||||||
data: '',
|
data: '',
|
||||||
|
|
|
@ -1,11 +1,19 @@
|
||||||
<div v-scope>
|
<div v-scope>
|
||||||
<input type="text" name="txt"
|
<input type="text" name="txt" autofocus
|
||||||
@change="mydata.save($el.value)" />
|
v-model="newdata"
|
||||||
|
@change="save" />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div v-scope>
|
<div v-scope>
|
||||||
<pre>id = {| urlParams.get('id') |}</pre>
|
<pre v-effect="$el.textContent = data" ></pre>
|
||||||
<pre v-effect="$el.textContent = mydata.data" ></pre>
|
</div>
|
||||||
|
|
||||||
|
<div v-scope>
|
||||||
|
<pre v-effect="$el.textContent = newdata" ></pre>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div v-scope>
|
||||||
|
<div>id = {| urlParams.get('id') |}</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue