やりたいこと
絶対パスでcomponentのパスを指定する。
プログラムのエラーは出ないが、エディタ(私が使用しているものはPhpstormです)で
「文法違いますよ」というエラー(黄色の破線)が出る。
紛らわしいので、なんとかしたい。
修正前
<script>
// @ is an alias to /src
import TheClientHeader from '../../components/object/project/TheClientHeader' //←★修正前コレ
export default {
name: 'Home',
components: { TheClientFooter },
}
</script>
修正後
<script>
// @ is an alias to /src
import TheClientHeader from '@/components/object/project/TheClientHeader' //←★修正後コレ(文法エラーの表記は出ていない)
export default {
name: 'Home',
components: { TheClientFooter },
}
</script>
解決方法
import-resolver.jsというファイルをドキュメントルート直下に作成し、
以下を記述
/* eslint-disable no-undef */
System.config({
paths: {
'@/*': 'src/*',
},
})