>  Q&A  >  본문

'prop'에 값이 할당되었지만 사용된 적이 없습니다. no-unused-vars vue3

<p>我的组件文件上使用。我的组件代码:</p> <pre class="brush:php;toolbar:false;"><템플릿> <router-link :to="{ 이름: routerName }" type="is-primary" class="inline-flex justify-center py-2 px-3 mb-3 border border-transparent Shadow-sm text-sm 글꼴-medium rounded-md text-white bg-red-600 hover:bg-red-700 초점:개요-없음 초점:링-2 초점:링-오프셋-2 초점:ring-indigo-500"> <svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5" fill="없음" viewBox="0 0 24 24" 스트로크="현재색상"> <경로 스트로크-라인캡="라운드" 스트로크-라인조인="라운드" 스트로크 너비 = "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;취소 </라우터-링크> </템플릿> <스크립트 설정> const 소품 = 정의Props({ 라우터 이름: { 유형: 문자열, 필수: 사실 } }) <p>但其返回eslint错误<code>'props'被赋值但从未使用过 no-unused-vars</code></p> <p>我已经는 내 package.json 上添加了如下规则:</p> <pre class="brush:php;toolbar:false;">"확장": [ "플러그인:vue/vue3-essential", "eslint:권장" ], "파서 옵션": { "파서": "@babel/eslint-parser" }, "규칙": { "vue/script-setup-uses-vars": "오류", "vue/다중 단어 구성 요소 이름": "끄기" }</pre> <p>仍然错误。내가 좋아하는 것은 다음과 같습니다</p> <pre class="brush:php;toolbar:false;">"devDependency": { "@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", "에슬린트": "^7.32.0", "eslint-plugin-vue": "^8.0.3" },</pre></p>
P粉810050669P粉810050669398일 전503

모든 응답(1)나는 대답할 것이다

  • P粉298305266

    P粉2983052662023-08-26 13:50:56

    (오류에 표시된 대로) 소품을 사용하지 않기 때문에 오류가 발생합니다. package.json의 규칙에 추가된 const props = 或(我建议)将 "no-unused-vars": "warn"를 제거할 수 있습니다.

    회신하다
    0
  • 취소회신하다