【问题标题】:VueJs Typescript ignore typescript error in template blockVueJs Typescript 忽略模板块中的 TypeScript 错误
【发布时间】:2022-11-18 22:28:03
【问题描述】:

是的,我是 VueJs 和 Typescript 的新手,但请不要告诉我这是多么糟糕的做法,因为 typescript 提供这行代码 //@ignore-ts 是有原因的。现在在我的 VueJs 应用程序中,一切都按预期工作。唯一让我恼火的是我的代码编辑器中模板块中的打字稿错误。是否有任何我找不到的选项类似于我在脚本块中所做的?

<script setup lang="ts">
//@ignore-ts
this line will be ignored of typescript errors
</script>

<template>
<!-- @ignore-ts -->
this does not work and this line still has a typescript error
</template>

here 提出了一个更全面的问题来解决我的问题

【问题讨论】:

    标签: typescript vue.js


    【解决方案1】:

    该错误可能由 TSLint/ESLint 显示,因此您可以禁用此验证。 您可以使用

    /* tslint:disable */ 
    

    /* tslint:enable */
    

    (这只能应用于有错误的行或块。 或者您只能禁用特定规则,查看更多详细信息here

    但是,我强烈建议您搜索错误以及是否有正确的方法来实现它(我知道它并不总是有)

    【讨论】:

    • 感谢您的回答!但这对我没有帮助。如果我在我的 <script> 块中使用 /* tslint:disable */,我的 <template> 块中仍然会抛出一个错误。如果您可能想检查一下,我已将我实际的打字稿问题发布在此 question 中。
    猜你喜欢
    • 2017-10-06
    • 2018-06-05
    • 2019-12-05
    • 2016-04-25
    • 2020-12-18
    • 1970-01-01
    • 2022-12-20
    • 2021-04-17
    • 2021-01-27
    相关资源
    最近更新 更多