setup-test.ts 467 B

1234567891011121314151617181920212223242526272829303132333435
  1. import Vue from '../index'
  2. // object props
  3. Vue.extend({
  4. props: {
  5. foo: String,
  6. bar: Number
  7. },
  8. setup(props) {
  9. props.foo + 'foo'
  10. props.bar + 123
  11. }
  12. })
  13. // array props
  14. Vue.extend({
  15. props: ['foo', 'bar'],
  16. setup(props) {
  17. props.foo
  18. props.bar
  19. }
  20. })
  21. // context
  22. Vue.extend({
  23. setup(_props, ctx) {
  24. if (ctx.attrs.id) {
  25. }
  26. ctx.emit('foo')
  27. ctx.slots.default && ctx.slots.default()
  28. ctx.expose({
  29. foo: 123
  30. })
  31. }
  32. })