【问题标题】:eslint [vue/no-unused-vars] error in vue templatevue 模板中的 eslint [vue/no-unused-vars] 错误
【发布时间】:2020-01-25 00:11:52
【问题描述】:

也许这对某人有用。

我有一个带有 html 的 vue 模板

<template slot="HEAD_Status" slot-scope="data">
    <!-- some html without using of data -->
</template>

而 Eslint generate [vue/no-unused-vars] 'data' 已定义但从未使用过。

我尝试使用 eslint-disable-line 没有任何成功(看起来是因为它在 vue 文件中):(

【问题讨论】:

    标签: html vue.js eslint


    【解决方案1】:

    我编辑我的模板:

    <template slot="HEAD_Status" slot-scope="{}"></template>
    

    例如将数据替换为槽范围内的 {}。

    看起来像另一种解决方案,我们可以将 html 从 vue 模板移动到 html 文件:

    <template src="./someTemaplte.html></template>
    

    然后在 someTemaplte.html 中插入我们的 html:

    <template slot="HEAD_Status" slot-scope="data"></template>
    

    附:我没有尝试移动到 html 文件的解决方案。

    【讨论】:

      猜你喜欢
      • 2020-07-24
      • 2019-07-06
      • 2020-02-17
      • 2018-06-27
      • 1970-01-01
      • 2020-03-01
      • 2020-01-25
      • 2020-07-21
      • 2019-01-12
      相关资源
      最近更新 更多