VueCli 使用 render + jsx 报错:You may need an additional loader to handle the result of these loaders

原文链接
Vue Render HTML - You may need an additional loader to handle the result of these loaders

环境:Vue 2.x

在 VueCli 中使用 render + jsx 报错:

Module parse failed: Unexpected token (224:36)
File was processed with these loaders:
 * ./node_modules/cache-loader/dist/cjs.js
 * ./node_modules/vue-loader/lib/index.js
You may need an additional loader to handle the result of these loaders.

报错代码:

headings: {
  id: 'ID',
  selected: function (h) {
    return <b-form-checkbox v-model={this.checkedAll} onChange={this.selectAll}>
          </b-form-checkbox>
  }
}

解决方法:
安装 babel 插件:https://github.com/vuejs/babel-plugin-transform-vue-jsx
在这里插入图片描述
安装命令:

npm install babel-plugin-syntax-jsx babel-plugin-transform-vue-jsx babel-helper-vue-jsx-merge-props babel-preset-env --save-dev

在 babel.config.js 配置:

module.exports = {
  presets: [
    '@vue/cli-plugin-babel/preset'
  ]
}

每天都要被百度的辣鸡搜索结果气死,最后还是通过不可访问的搜索引擎,几秒搜到解决方案。stackoverflow YYDS
注:配置babel.config.js的前提是,项目安装了@vue/cli-plugin-babel,我使用的是@3.7.0版本。

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 5
    评论
评论 5
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值