2023-12-10 01:33:18 +08:00
|
|
|
import { watch } from 'vue'
|
|
|
|
import {
|
|
|
|
children,
|
|
|
|
on,
|
|
|
|
ref,
|
2023-12-29 22:05:33 +08:00
|
|
|
render as renderComponent,
|
2023-12-10 01:33:18 +08:00
|
|
|
setText,
|
2023-12-29 22:05:33 +08:00
|
|
|
template,
|
|
|
|
watchEffect, // TODO:
|
2023-12-10 01:33:18 +08:00
|
|
|
} from '@vue/vapor'
|
|
|
|
|
|
|
|
export default {
|
|
|
|
props: undefined,
|
|
|
|
|
|
|
|
setup(_, {}) {
|
|
|
|
const count = ref(1)
|
|
|
|
const handleClick = () => {
|
|
|
|
count.value++
|
|
|
|
}
|
|
|
|
|
|
|
|
const __returned__ = { count, handleClick }
|
|
|
|
|
|
|
|
Object.defineProperty(__returned__, '__isScriptSetup', {
|
|
|
|
enumerable: false,
|
2023-12-29 22:05:33 +08:00
|
|
|
value: true,
|
2023-12-10 01:33:18 +08:00
|
|
|
})
|
|
|
|
|
|
|
|
return __returned__
|
|
|
|
},
|
|
|
|
|
|
|
|
render(_ctx) {
|
|
|
|
const t0 = template('<button></button>')
|
|
|
|
const n0 = t0()
|
|
|
|
const {
|
2023-12-29 22:05:33 +08:00
|
|
|
0: [n1],
|
2023-12-10 01:33:18 +08:00
|
|
|
} = children(n0)
|
|
|
|
on(n1, 'click', _ctx.handleClick)
|
2023-12-23 15:17:18 +08:00
|
|
|
watchEffect(() => {
|
2023-12-10 01:33:18 +08:00
|
|
|
setText(n1, void 0, _ctx.count)
|
|
|
|
})
|
|
|
|
|
|
|
|
// TODO: create component fn?
|
|
|
|
// const c0 = createComponent(...)
|
|
|
|
// insert(n0, c0)
|
|
|
|
renderComponent(
|
|
|
|
child,
|
|
|
|
|
|
|
|
// TODO: proxy??
|
|
|
|
{
|
|
|
|
/* <Comp :count="count" /> */
|
|
|
|
get count() {
|
|
|
|
return _ctx.count
|
|
|
|
},
|
|
|
|
|
|
|
|
/* <Comp :inline-double="count * 2" /> */
|
|
|
|
get inlineDouble() {
|
|
|
|
return _ctx.count * 2
|
2023-12-29 22:05:33 +08:00
|
|
|
},
|
2023-12-10 01:33:18 +08:00
|
|
|
},
|
2023-12-29 22:05:33 +08:00
|
|
|
n0,
|
2023-12-10 01:33:18 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
return n0
|
2023-12-29 22:05:33 +08:00
|
|
|
},
|
2023-12-10 01:33:18 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
const child = {
|
|
|
|
props: {
|
|
|
|
count: { type: Number, default: 1 },
|
2023-12-29 22:05:33 +08:00
|
|
|
inlineDouble: { type: Number, default: 2 },
|
2023-12-10 01:33:18 +08:00
|
|
|
},
|
|
|
|
|
|
|
|
setup(props) {
|
|
|
|
watch(
|
|
|
|
() => props.count,
|
2023-12-29 22:05:33 +08:00
|
|
|
v => console.log('count changed', v),
|
2023-12-10 01:33:18 +08:00
|
|
|
)
|
|
|
|
watch(
|
|
|
|
() => props.inlineDouble,
|
2023-12-29 22:05:33 +08:00
|
|
|
v => console.log('inlineDouble changed', v),
|
2023-12-10 01:33:18 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
const __returned__ = {}
|
|
|
|
|
|
|
|
Object.defineProperty(__returned__, '__isScriptSetup', {
|
|
|
|
enumerable: false,
|
2023-12-29 22:05:33 +08:00
|
|
|
value: true,
|
2023-12-10 01:33:18 +08:00
|
|
|
})
|
|
|
|
|
|
|
|
return __returned__
|
|
|
|
},
|
|
|
|
|
|
|
|
render(_ctx) {
|
|
|
|
const t0 = template('<p></p>')
|
|
|
|
const n0 = t0()
|
|
|
|
const {
|
2023-12-29 22:05:33 +08:00
|
|
|
0: [n1],
|
2023-12-10 01:33:18 +08:00
|
|
|
} = children(n0)
|
2023-12-23 15:17:18 +08:00
|
|
|
watchEffect(() => {
|
2023-12-10 01:33:18 +08:00
|
|
|
setText(n1, void 0, _ctx.count + ' * 2 = ' + _ctx.inlineDouble)
|
|
|
|
})
|
|
|
|
return n0
|
2023-12-29 22:05:33 +08:00
|
|
|
},
|
2023-12-10 01:33:18 +08:00
|
|
|
}
|