首頁  >  問答  >  主體

未使用的定義:“HelloWorld”

App.vue 檔案

<template lang="pug">
div
  hello-world
</template>
<script setup lang="ts">
import HelloWorld from "./components/HelloWorld.vue";
</script>

HelloWorld.vue 檔案

<template lang="pug">
div
  h1 {{ msg }}
</template>

<script setup lang="ts">
import { ref } from "vue";

const msg = ref<string>("Hello World!!!");
</script>

問題是什麼以及如何解決?在 vue3 中同時使用 typescript、composition API 和 pug 範本時遇到此問題。關心的是如何使用組合 API 導入元件並在 pug 模板中使用它?

P粉106711425P粉106711425204 天前405

全部回覆(1)我來回復

  • P粉762447363

    P粉7624473632024-03-30 11:27:24

    我很確定問題來自預先安裝打字稿。刪除打字稿作為腳本語言應該可以解決問題: