Vue + typescript 挖坑記
VueCli3.0生成Vue+ts的項目元件,中間遇到了一些讓我直接放棄結合ts的坑,還是等Vue3.0的釋出吧,到那個時候肯定結合得會更好。
1 How to fix TSLint: " should be ' (quotemark) while doing organize imports in code editors?
In User Preferences set the following.
"tslint.autoFixOnSave": true
複制
2 tslint Missing semicolon (semicolon)
分析:在vuetur的github>issue中有講,vue-tslint的代碼檢查不太好,強制要求每個vue單檔案元件裡必須要有以下代碼
<script lang="ts">
</script>
複制
3 App.vue' is not a module.
分析:弄完第二個問題後,cli緊接着就報了這個錯誤。想了解的話,請戳vuecli_ts > Github上的這個Issue,下面給了一種臨時性的解決方案(真的挺醜的),真正的解決還是得等vue3.0的正式釋出。
解決方法:// @ts-ignore before each import '*.vue' could be a temporary solution.
// @ts-ignore
import HelloWorld from '@/components/HelloWorld/HelloWorld.vue';
複制