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

相关推荐
We་ct1 小时前
LeetCode 205. 同构字符串:解题思路+代码优化全解析
前端·算法·leetcode·typescript
2301_812731412 小时前
CSS3笔记
前端·笔记·css3
ziblog2 小时前
CSS3白云飘动动画特效
前端·css·css3
越努力越幸运5082 小时前
CSS3学习之网格布局grid
前端·学习·css3
半斤鸡胗2 小时前
css3基础
前端·css
ziblog2 小时前
CSS3创意精美页面过渡动画效果
前端·css·css3
akangznl2 小时前
第四章 初识css3
前端·css·css3·html5
会豪2 小时前
深入理解 CSS3 滤镜(filter):从基础到实战进阶
前端·css·css3
头顶一只喵喵2 小时前
CSS3进阶知识:CSS3盒子模型,box-sizing:content-box和box-sizing:border-box的讲解
前端·css·css3
小飞大王6662 小时前
css进阶用法
前端·css