Vue - Official插件升级vue文件报错

1.兼容性问题

Volar这一块强大的插件升级之后变成Vue - Official,但是这个兼容性的问题还是存在不少的,比如# automatically enable Hybrid Mode,github社区上给出的答案,是把原来的auto改成true

2.创建的vue文件报错

自己创建的vue文件 和在 router路由文件中,使用的组件也会莫名的报错 大概提示为: 没有声明这些组件, ts无法识别
解决办法: 自己声明创建的vue文件(在 env.d.ts 中声明)

js 复制代码
/// <reference types="vite/client" />

declare module "*.vue" {
  import type { DefineComponent } from "vue"
  const component: DefineComponent
  export default component
}

3.升级Vue - Official 的版本后,初始化 JS/TS 语言服务会崩溃

The JS/TS language service immediately crashed 5times. The service will not be restarted. This may becaused by a plugin contributed by one of theseextensions: Vue.volar. Please try disabling theseextensions before filing an issue against VS Code.

解决方案是降级 github.com/vuejs/langu... 注意:这个针对的版本是 v2.0.3 不过现在最新的Vue - Official版本2.0.11(时间是24年4月10号安装),已经解决的这个问题

4.Vue - Official插件的一些优点

4.1.同名属性的简写

js 复制代码
<template>
   <div class="home">
     <home :itemData="itemData"/>
   </div>
</template>

同名属性的简写

js 复制代码
<template>
   <div class="home">
     <home :itemData/>
   </div>
</template>

4.2. 拖拽导入组件

Mac电脑,需要先试用 command键, 拖动需要拖拽的 vue组件, 到编辑区域, 然后切换 shift

相关推荐
jlspcsdn1 小时前
20251222项目练习
前端·javascript·html
行走的陀螺仪1 小时前
Sass 详细指南
前端·css·rust·sass
爱吃土豆的马铃薯ㅤㅤㅤㅤㅤㅤㅤㅤㅤ1 小时前
React 怎么区分导入的是组件还是函数,或者是对象
前端·react.js·前端框架
LYFlied2 小时前
【每日算法】LeetCode 136. 只出现一次的数字
前端·算法·leetcode·面试·职场和发展
子春一22 小时前
Flutter 2025 国际化与本地化工程体系:从多语言支持到文化适配,打造真正全球化的应用
前端·flutter
QT 小鲜肉2 小时前
【Linux命令大全】001.文件管理之file命令(实操篇)
linux·运维·前端·网络·chrome·笔记
羽沢313 小时前
ECharts 学习
前端·学习·echarts
LYFlied3 小时前
WebAssembly (Wasm) 跨端方案深度解析
前端·职场和发展·wasm·跨端
七月丶3 小时前
实战复盘:我为什么把 TypeScript 写的 CLI 工具用 Rust 重写了一遍?
前端·后端·rust