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

相关推荐
与光_同尘3 分钟前
一个隐蔽的 DOM 陷阱:id="nodeName" 引发的血案
前端
雲墨款哥4 分钟前
React小demo,评论列表
前端·react.js
青瓜达利园5 分钟前
zustand 入门
前端
triumph_passion7 分钟前
Tailwind CSS v4 深度指南:目录架构与主题系统
前端·css
UIUV8 分钟前
React表单处理:受控组件与非受控组件全面解析
前端·javascript·react.js
henry9 分钟前
React Native 横向滚动指示器组件库(淘宝|京东...&旧版|新版)
前端
一只爱吃糖的小羊10 分钟前
JSBridge 传参陷阱:h5明明传了参数,安卓却收到为空
前端·javascript
实习生小黄13 分钟前
window.print 实现简单打印
前端·javascript
Wect14 分钟前
LeetCode 26.删除有序数组中的重复项:快慢指针的顺势应用
前端·typescript