跳至主要內容

6. ⚡Simple Vue

鸭梨小于 1 分钟

6. ⚡Simple Vue

<题目描述>

::: playground#ts 6. Simple Vue

@file index.ts

// ============= Test Cases =============
import type { Equal, Expect } from '@type-challenges/utils'

SimpleVue({
  data() {
    // @ts-expect-error
    this.firstname
    // @ts-expect-error
    this.getRandom()
    // @ts-expect-error
    this.data()

    return {
      firstname: 'Type',
      lastname: 'Challenges',
      amount: 10,
    }
  },
  computed: {
    fullname() {
      return `${this.firstname} ${this.lastname}`
    },
  },
  methods: {
    getRandom() {
      return Math.random()
    },
    hi() {
      alert(this.amount)
      alert(this.fullname.toLowerCase())
      alert(this.getRandom())
    },
    test() {
      const fullname = this.fullname
      const cases: [Expect<Equal<typeof fullname, string>>] = [] as any
    },
  },
})

// ============= Your Code Here =============
declare function SimpleVue(options: any): any

:::

点击查看答案
// 你的答案