実現したいこと
ご覧いただき、誠にありがとうございます。
vue@3.5.17 で、親コンポーネントから子コンポーネントに変数を【一つ】渡したいだけの、きわめて単純なソースです。
下記のソースで詳細を示します。
子コンポーネントで定義した変数「text」にて、親コンポーネントで指定した「本日は晴天なり」を表示させるのが目的です。
【わからないこと】
子コンポーネントの<script setup>におけるdefinePropsの書き方が悪いのか、もしくはESLintの設定が不正なのかが見当がつかない状態です。
エラーメッセージ
error
1/app/hoge/src/components/Test01.vue 2 XXX:1 error 'defineProps' is not defined no-undef 3 4//上記エラー以外は何も表示されていませんでした。
//● yarnのログで出力されたエラー。 INFO Starting development server... ERROR Failed to compile with 1 error 1:21:58 PM [eslint] /app/hoge/src/components/Test01.vue 6:1 error 'defineProps' is not defined no-undef
//【修正後】
module.exports = { root: true, extends: ['plugin:vue-libs/recommended'], rules: { indent: 'off', 'space-before-function-paren': 'off' }, globals: { "defineProps": "readonly", "defineEmits": "readonly", "defineExpose": "readonly", "withDefaults": "readonly" } }
試したこと・調べたこと
- teratailやGoogle等で検索した
- ソースコードを自分なりに変更した
- 知人に聞いた
- その他
上記の詳細・結果
【参考にしたサイト】
(1)ESLintに'defineProps' is not defined.(no-undef)と言われる
https://commis.hatenablog.com/entry/2021/10/21/113831
(2)'defineProps' is not defined #15015
https://github.com/eslint/eslint/discussions/15015
補足
【Vueのバージョンと、関連ライブラリのバージョン】
shell
1+-- @babel/core@7.27.7 2+-- @babel/eslint-parser@7.27.5 3+-- @vue/cli-plugin-babel@5.0.8 4+-- @vue/cli-plugin-eslint@5.0.8 5+-- @vue/cli-service@5.0.8 6+-- core-js@3.43.0 7+-- eslint-plugin-vue@8.7.1 8+-- eslint@7.32.0 9`-- vue@3.5.17 10
Vueの環境は、Windows11のWSL2-Ubuntu内、Dockerで構築しました。
(参考)Dockerfileの内容
Dockerfile
1 2FROM node:lts-alpine 3 4# vue-cliをインストール 5RUN apk update && \ 6 apk add --no-cache npm && \ 7 npm install --location=global @vue/cli 8 9WORKDIR /app 10
(参考)docker-compose.ymlの内容
yaml
1version: '3' 2 3services: 4 vue-app: 5 build: 6 context: "./" 7 dockerfile: "Dockerfile" 8 ports: 9 - 8080:8080 10 volumes: 11 - ./app:/app 12 tty: true 13 environment: 14 - NODE_ENV=development
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。