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

相关推荐
灰小猿7 小时前
Spring前后端分离项目时间格式转换问题全局配置解决
java·前端·后端·spring·spring cloud
im_AMBER7 小时前
React 16
前端·笔记·学习·react.js·前端框架
02苏_7 小时前
ES6模板字符串
前端·ecmascript·es6
excel7 小时前
⚙️ 一次性警告机制的实现:warnOnce 源码深度解析
前端
excel7 小时前
Vue SFC 样式编译核心机制详解:compileStyle 与 PostCSS 管线设计
前端
excel7 小时前
🧩 使用 Babel + MagicString 实现动态重写 export default 的通用方案
前端
excel7 小时前
Vue SFC 编译器主导出文件解析:模块组织与设计哲学
前端
excel7 小时前
深度解析:Vue SFC 模板编译器核心实现 (compileTemplate)
前端
excel7 小时前
Vue SFC 解析器源码深度解析:从结构设计到源码映射
前端
excel7 小时前
Vue SFC 编译全景总结:从源文件到运行时组件的完整链路
前端