example code using v-model and v-effect

This commit is contained in:
Helmut Merz 2023-02-19 15:08:52 +01:00
parent ad1c48b7ed
commit bba0177f9f
2 changed files with 19 additions and 5 deletions

View file

@ -3,9 +3,15 @@ import { createApp } from './lib/petite-vue.es.js'
createApp({
$delimiters: ['{|', '|}'],
urlParams: new URL(location.href).searchParams,
mydata: Data(),
newdata: '',
data: '',
save
}).mount()
function save() {
this.data += '\n' + this.newdata
}
function Data() {
return {
data: '',

View file

@ -1,11 +1,19 @@
<div v-scope>
<input type="text" name="txt"
@change="mydata.save($el.value)" />
<input type="text" name="txt" autofocus
v-model="newdata"
@change="save" />
</div>
<div v-scope>
<pre>id = {| urlParams.get('id') |}</pre>
<pre v-effect="$el.textContent = mydata.data" ></pre>
<pre v-effect="$el.textContent = data" ></pre>
</div>
<div v-scope>
<pre v-effect="$el.textContent = newdata" ></pre>
</div>
<div v-scope>
<div>id = {| urlParams.get('id') |}</div>
</div>