输入参比组分API Vue

bis0qfac  于 2023-02-24  发布在  Vue.js
关注(0)|答案(1)|浏览(210)

我怎样才能正确地把我的Ref firstName作为字符串输入呢?有两个带下划线的错误,在模板中-{{ firstName }},在脚本中-const firstName = ref('') as String。我想这与输入有关,因为我认为Ref工作正常。

<template>
  </div> -->
  <v-sheet >
      <v-form fast-fail @submit.prevent>
        <v-text-field
          label="First name"
        >{{ firstName }}</v-text-field>
      </v-form>
    </v-sheet>
</template>
<script lang="ts">
import { ref } from 'vue'
export default {
  setup() {
    const firstName = ref('') as String
  },
  }
</script>
qybjjes1

qybjjes11#

根据两条评论汇编
<script>版本

<script lang="ts">
import { ref } from 'vue'
export default {
  setup() {
    const firstName = ref<string>('Alexander')
    return {firstName}
  }
}
</script>

<template>
  {{ firstName }}
</template>

<script setup>版本

<script setup lang="ts">
import { ref } from 'vue'
const firstName = ref<string>('Alexander')
</script>

<template>
  {{ firstName }}
</template>

证监会Playground

相关问题