vue cli3 如何使用jsx?

项目开始

vue create .
# 默认配置

代码:

export default {
  render(h) {
    return (<div>11</div>);
  }
}

尝试过的:

方案1

https://github.com/vuejs/jsx#...

Install the preset with:

npm install @vue/babel-preset-jsx @vue/babel-helper-vue-jsx-merge-props

Then add the preset to.babelrc:

{
  "presets": \["@vue/babel-preset-jsx"\]
}

报错

Module parse failed: Unexpected token (62:12)
File was processed with these loaders:
 * ./node_modules/eslint-loader/index.js
You may need an additional loader to handle the result of these loaders.
|   },
|   render(h) {
>     return (<div>11</div>);
|   }

方案二

https://github.com/vuejs/babe...

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

In your.babelrc:

{
  "presets": \["env"\],
  "plugins": \["transform-vue-jsx"\]
}

报错 同上

方案三:

https://segmentfault.com/q/10... @zangeci 的问答

报错 同上

阅读 3.8k
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题
宣传栏