import Vue, { defineComponent, PropType } from '../../index'
Vue.extend({
props: {
foo: String,
bar: Number
},
setup(props) {
props.foo + 'foo'
props.bar + 123
}
})
Vue.extend({
props: ['foo', 'bar'],
setup(props) {
props.foo
props.bar
}
})
Vue.extend({
setup(_props, ctx) {
if (ctx.attrs.id) {
}
ctx.emit('foo')
ctx.slots.default && ctx.slots.default()
ctx.expose({
a: 123
})
}
})
defineComponent({
props: {
foo: String,
bar: Number
},
setup(props) {
props.foo.slice(1, 2)
props.foo?.slice(1, 2)
props.bar + 123
props.bar?.toFixed(2)
}
})
defineComponent({
props: ['foo', 'bar'],
setup(props) {
props.foo
props.bar
}
})
defineComponent({
emits: ['foo'],
setup(_props, ctx) {
if (ctx.attrs.id) {
}
ctx.emit('foo')
ctx.emit('ok')
ctx.slots.default && ctx.slots.default()
},
methods: {
foo() {
this.$emit('foo')
this.$emit('bar')
}
}
})
defineComponent({
props: {
foo: null as any as PropType<{ a: number }>
},
data() {
this.foo?.a
},
setup(props) {
const res = props.foo?.a.toFixed(2)
res.charAt(1)
res?.charAt(1)
}
})
const vm = new Vue({
setup() {},
render: h => h({})
})
vm.$mount('#app')