首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >“‘props”被分配一个值,但从未使用未使用的-vars vue3。

“‘props”被分配一个值,但从未使用未使用的-vars vue3。
EN

Stack Overflow用户
提问于 2022-11-13 02:39:28
回答 1查看 45关注 0票数 0

我在我的vue组件文件上使用。我的组件代码:

代码语言:javascript
运行
复制
<template>
    <router-link :to="{ name: routerName }" type="is-primary"
        class="inline-flex justify-center py-2 px-3 mb-3 border border-transparent shadow-sm text-sm font-medium rounded-md text-white bg-red-600 hover:bg-red-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500">
        <svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5" fill="none" viewBox="0 0 24 24" stroke="currentColor">
            <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
                d="M10 14l2-2m0 0l2-2m-2 2l-2-2m2 2l2 2m7-2a9 9 0 11-18 0 9 9 0 0118 0z" />
        </svg>&nbsp;Cancel
    </router-link>
</template>

<script setup>
const props = defineProps({
    routerName: {
        type: String,
        required: true
    }
})
</script>

但它的返回误差为'props' is assigned a value but never used no-unused-vars

我已经在我的package.json上添加了如下规则:

代码语言:javascript
运行
复制
    "extends": [
      "plugin:vue/vue3-essential",
      "eslint:recommended"
    ],
    "parserOptions": {
      "parser": "@babel/eslint-parser"
    },
    "rules": {
            "vue/script-setup-uses-vars": "error",
      "vue/multi-word-component-names": "off"
    }

仍然是错误。我的devDepedencies:

代码语言:javascript
运行
复制
  "devDependencies": {
    "@babel/core": "^7.12.16",
    "@babel/eslint-parser": "^7.12.16",
    "@vue/cli-plugin-babel": "~5.0.0",
    "@vue/cli-plugin-eslint": "~5.0.0",
    "@vue/cli-service": "~5.0.0",
    "eslint": "^7.32.0",
    "eslint-plugin-vue": "^8.0.3"
  },
EN

回答 1

Stack Overflow用户

发布于 2022-11-13 03:23:44

您得到错误是因为(正如错误所指出的)您从不使用道具。您可以删除const props =或(我建议的)将"no-unused-vars": "warn"添加到package.json中的规则中。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/74418097

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档