第一次做vue3的项目的时候,从网上找了一个现成的框架进行开发,刚开始开发使用element-plus的时候,我直接把ui代码粘贴进我的项目中,发现代码报错,错误如下:
Compiled with problems:

ERROR in ./src/views/layoutpages/system/Menus.vue?vue&type=template&id=07e451a3&ts=true (./node_modules/vue-loader/dist/templateLoader.js??ruleSet[1].rules[3]!./node_modules/vue-loader/dist/index.js??ruleSet[0].use[0]!./src/views/layoutpages/system/Menus.vue?vue&type=template&id=07e451a3&ts=true) 7:27

Module parse failed: Unexpected token (7:27)
File was processed with these loaders:

  • ./node_modules/vue-loader/dist/templateLoader.js
  • ./node_modules/vue-loader/dist/index.js
    You may need an additional loader to handle the result of these loaders.
    | const _hoisted_3 = /#PURE/_createTextVNode(“Cancel”)
    |
    export function render(_ctx: any,_cache: any, p r o p s : a n y , props: any, props:any,setup: any, d a t a : a n y , data: any, data:any,options: any) {
    | const _component_el_input = _resolveComponent(“el-input”)!
    | const _component_el_form_item = _resolveComponent(“el-form-item”)!
    我感觉我的代码没问题啊!
    在这里插入图片描述

找了好久的问题,最后才发现是因为这个我网上拉下来的框架,它不支持typescript语法😂😂😂😂,这个问题真的太蠢了!!!
解决办法:
1.把script标签的lang="ts"去掉,当然这样你项目中就不能使用ts语法了
在这里插入图片描述
2.如果想要使用ts语法,那就需要另外引入typescript
具体引入方法见下:
在这里插入图片描述

Logo

为开发者提供学习成长、分享交流、生态实践、资源工具等服务,帮助开发者快速成长。

更多推荐