質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.47%
Vue.js

Vue.jsは、Webアプリケーションのインターフェースを構築するためのオープンソースJavaScriptフレームワークです。

Ruby on Rails 6

Ruby on Rails 6は、オープンソースのWebアプリケーションフレームワークです。「同じことを繰り返さない」というRailsの基本理念のもと、他のフレームワークより少ないコードで簡単に開発できるよう設計されています。

Q&A

1回答

1844閲覧

Vue.js Parsing error: 'from' expectedエラー

manaka6122

総合スコア0

Vue.js

Vue.jsは、Webアプリケーションのインターフェースを構築するためのオープンソースJavaScriptフレームワークです。

Ruby on Rails 6

Ruby on Rails 6は、オープンソースのWebアプリケーションフレームワークです。「同じことを繰り返さない」というRailsの基本理念のもと、他のフレームワークより少ないコードで簡単に開発できるよう設計されています。

0グッド

0クリップ

投稿2022/06/07 04:49

前提

Ruby on Rails とVue.jsでカレンダーを作っています。
2つのコンポーネント間でデータを共有を実装中に以下のエラーメッセージが発生しました。

実現したいこと

  • Vuexを使ってコンポーネント間でデータを共有する
  • CalenderのデータをCalendarDetailsで共有

発生している問題・エラーメッセージ

Module parse failed: Unexpected token (3:0) File was processed with these loaders: * ./node_modules/vue-loader/dist/index.js You may need an additional loader to handle the result of these loaders. | | import {} > import { mapGetters, mapActions } from 'vuex'; | import CalendarDetails from './CalendarDetails.vue'; | ERROR /Users/xxxxxxxxxxx/Desktop/Calendar/frontend/src/components/Calendar.vue 16:0 error Parsing error: 'from' expected``` ### 該当のソースコード

Calendar.vue

1<template> 2 --- 3</template> 4<script> 5import {} 6import { mapGetters, mapActions } from 'vuex'; 7import CalendarDetails from './CalendarDetails.vue'; 8 9export default { mapGetters, mapActions } from 'vuex'; 10 name: 'Calendar', 11 components: { 12 CalendarDetails, 13 }, 14 computed: { 15 ...mapGetters('events', ['events']), 16 }, 17 methods: { 18 ...mapActions('events', ['fetchEvents']), 19 }, 20}; 21</script>

events.js

1import axios from 'axios'; 2 3const apiUrl = 'http://localhost:3000'; 4 5const state = { 6 event: [], 7}; 8 9const getters = { 10 events: (state) => state.events, 11}; 12 13const mutations = { 14 setEvents: (state, events) => (state.events = events), 15}; 16 17const actions = { 18 async fetchEvents({ commit }) { 19 const response = await axios.get(`${apiUrl}/events`); 20 commit('setEvents', response.data); 21 }, 22}; 23 24export default { 25 namespace: true, 26 state, 27 getters, 28 mutations, 29 actions, 30}; 31

index.js

1import { createStore } from 'vuex'; 2import events from './modules/events'; 3 4export default createStore({ 5 state: {}, 6 getters: {}, 7 mutations: {}, 8 actions: {}, 9 modules: { 10 events, 11 }, 12});
module.exports = { plugins: ['@typescript-eslint'], parser: 'vue-eslint-parser', root: true, env: { node: true, }, extends: [ 'plugin:vue/base', 'plugin:vue/vue3-essential', 'eslint:recommended', 'plugin:prettier/recommended', 'plugin:vue/recommended', 'plugin:@typescript-eslint/eslint-recommended', ], parserOptions: { ecmaVersion: 7, sourceType: 'module', parser: '@typescript-eslint/parser', ecmaFeatures: { jsx: true, modules: true }, }, rules: { 'no-console': process.env.NODE_ENV === 'production' ? 'warn' : 'off', 'no-debugger': process.env.NODE_ENV === 'production' ? 'warn' : 'off', 'vue/multi-word-component-names': 0, 'no-undef': 'off', 'no-unused-vars': 'off', strict: 'off', 'vue/no-unused-components': 'off', }, };

試したこと

tslintを使わずにtypescript系のlintエラー対応する方法の記事を参考にし依存パッケージをインストールしました。

json

1{ 2 "root": true, 3 "extends": ["plugin:vue/recommended"], 4 "parserOptions": { 5 "parser": "@typescript-eslint/parser" 6 }, 7 "plugins": ["@typescript-eslint"], 8 "rules": { 9 "no-undef": "off", 10 "no-unused-vars": "off", 11 "strict": "off" 12 } 13}

sh

1npm i -D @typescript-eslint/eslint-plugin @typescript-eslint/parser eslint-plugin-vue

エラーは解決せず、ほのかの記事も同じような記述方だったので解決方法がわかりません。

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

guest

回答1

0

エラー発生行の直上にある「import {}」は不要ではないでしょうか

javascript

1import {} // <-- 2import { mapGetters, mapActions } from 'vuex';

投稿2022/06/07 05:21

Matsumon0104

総合スコア1005

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

まだベストアンサーが選ばれていません

会員登録して回答してみよう

アカウントをお持ちの方は

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.47%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問