[英]How to import typescript files in vue3 component?
我只用 vue3。 我想在 *.vue 文件中導入打字稿文件,例如:
<script lang="ts">
import { Option } from './data.ts'
</script>
在 data.ts 中:
type Option={
value: number,
text: string
}
export {
Option
}
我有錯誤:
An import path cannot end with a '.ts' extension. Consider importing './data' instead.
ts
和js
文件在沒有擴展名的情況下解析:
import { Option } from './data' //refers to /data.ts
如果文件夾在其根目錄中包含一個名為index.js
的文件,則可以在不指定index.js
情況下解析該文件夾
import store from './store' // store is a folder that contains `index.js`
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.