Skip to content

如果源文件import了其他vue组件且没有明确添加.vue后缀,希望转换为ts版本的vue之后可以将.vue后缀给补全。 #6

@nongcundeshifu

Description

@nongcundeshifu

假设下面的.vue文件引入了另外的一个vue组件,且没有显示指定 .vue 后缀:
转换前代码:

// 这一句import没有指定ImageList.vue组件的 .vue 后缀,这在普通的.vue文件中可以被ide识别,没有问题。
<script>
import ImageList from '@component/ImageList'
// other
</script>

但是转换为ts版本的.vue文件之后:

<script lang="ts">
// 转换后,如果这里没有指定 .vue 的后缀,那么ts在解析时会报错:无法找到这个模块,因为ts默认只识别 ts tsx jsx这几种,需要显示指定 .vue 文件后缀。
import ImageList from '@component/ImageList'
// other
</script>

如果转换时能自动为相应的vue组件引用添加上 .vue 后缀,会方便很多。
这并不是bug,只是一个优化建议。

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions