淘先锋技术网

首页 1 2 3 4 5 6 7

Ant-design官方文档提供了js和ts两种案例,按照文档给项目install ant-design后写了个组件编译时发现只要加上`<script >`就会得到错误:

Module parse failed: Unexpected token (5: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_1 = _createElementVNode("div", null, null, -1 )
|
> export function render(_ctx: any,_cache: any,$props: any,$setup: any,$data: any,$options: any) {
|   return (_openBlock(), _createElementBlock(_Fragment, null, [
|     _createCommentVNode(" <HomeView /> "),

ERROR in ./src/views/InsetView.vue?vue&type=template&id=2c537f98&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/InsetView.vue?vue&type=template&id=2c537f98&ts=true) 5:27
Module parse failed: Unexpected token (5:27)

搜索了一圈很多说修改配置文件的,其实只需要通过如下命令安装@vue/cli-plugin-typescript即可启用ts支持。

vue add typescript