vue文件中setup下面有蓝色波浪线
// setup有蓝色波浪线
<script setup></script>
解决方案1:
<script setup lang="ts"></script>
解决方案2:
在tsconfig.json
与tsconfig.node.json
中的compilerOptions添加:
"compilerOptions": {
"allowJs": true,
}
vite.config.ts中通过import引入的插件都有红色波浪线
例如:
import { defineConfig } from 'vite'
解决方案:
在tsconfig.json
与tsconfig.node.json
中的compilerOptions添加:
"compilerOptions": {
"moduleResolution":"node"
}
vue文件中通过import引入的xxx.vue有红色波浪线
例如:
import xxx from '@/views/xxx.vue'
解决方案:
在src
目录文件夹下新建一个xx.d.ts文件,输入以下内容:
declare module '*.vue' {
import { ComponentOptions } from 'vue'
const componentOptions: ComponentOptions
export default componentOptions
}
使用window对象添加属性报错
还是在src
目录文件夹下xx.d.ts文件中,添加以下代码:
declare interface Window{
obj: any;
}
这样就可以使用window.obj了