vue3.0 + ts + eslint报错:error Parsing error: ‘>‘ expected

在这里插入图片描述
eslint报错
这里加上对应的 eslint配置即可:

parser: 'vue-eslint-parser',
parserOptions: {
  parser: "@typescript-eslint/parser",
  ecmaVersion: 2020,
  sourceType: 'module',
}

具体如下:

module.exports = {
  parser: 'vue-eslint-parser',
  parserOptions: {
 	parser: "@typescript-eslint/parser",
    ecmaVersion: 2020,
    sourceType: 'module',
  },
  extends: [
    // 添加 ESLint 扩展规则
    'plugin:vue/vue3-recommended',
    // 添加其他 ESLint 扩展规则
  ],
  rules: {
    // 覆盖或添加自定义 ESLint 规则
  },
};

这个配置是在ESLint中指定Vue文件的解析器。在.eslintrc.js或.eslintrc.ts文件中,“parser”: "vue-eslint-parser"表示ESLint应该使用vue-eslint-parser来解析.vue文件。这是因为.vue文件是由HTML、CSS和JavaScript(或TypeScript)组成的单文件组件,而ESLint默认不理解这种文件格式。

vue-eslint-parser是一个独立的npm包,它提供了一个解析器,可以让ESLint理解Vue文件的语法。

如果你在使用Vue 3.0和TypeScript,并且已经正确安装了vue-eslint-parser和所需的Vue ESLint插件(如@vue/eslint-plugin-vue),那么这个配置应该是必要的。

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Vue 3.0是一个非常流行的JavaScript框架,不仅易于学习和使用,而且可以与许多UI框架集成。ElementUI是一种流行的UI框架,提供了许多易于使用的UI组件和效果。在Vue 3.0中,可以使用TypeScript(TS)编写代码,提供了更好的类型安全和代码可读性。下面是在Vue 3.0中引用ElementUI的步骤: 1. 安装ElementUI:可以使用npm或yarn命令安装ElementUI ``` npm i element-plus -S ``` 2. 使用TypeScript的话需要安装依赖 `ts` 和 `webpack`(如果没有的话) ``` npm i webpack webpack-cli webpack-dev-server typescript ts-loader -D ``` 3. 在Vue项目中引入ElementUI样式和组件: 3.1 引入样式(会自动挂载到全局样式表上) ```scss // main.ts import 'element-plus/dist/index.css' ``` 3.2 引入组件 ```js // main.ts or other entry file import { createApp } from 'vue' import App from './App.vue' import ElementPlus from 'element-plus' import 'element-plus/styles/index.css' // 引入组件样式 const app = createApp(App) app.use(ElementPlus) // 注册全局组件 app.mount('#app') ``` 这样就可以通过引入ElementPlus来使用ElementUI组件了。例如,在Vue 3.0中使用一个按钮组件: ```vue <template> <el-button type="primary">click me</el-button> </template> <script lang="ts"> import { defineComponent } from 'vue' import { ElButton } from 'element-plus' export default defineComponent({ name: 'MyButton', components: { ElButton } // 局部注册组件 }) </script> ``` 总的来说,引用ElementUI到Vue 3.0中相对比较简单,只需要安装依赖与组件后进行注册即可正常使用。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值