-
Notifications
You must be signed in to change notification settings - Fork 3.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
uniapp开发小程序什么支持vue3 jsx开发模式 #2245
Comments
+1 希望能支持jsx |
隔壁怎么支持的,试了不行啊 |
隔壁可以的,装个vue官方jsx插件@vue/babel-plugin-jsx,和web配置一毛一样小程序就可以用了 |
看看这个issue,还在合并中 |
这仅仅只是还不支持.jsx文件,.vue文件里面是可以的,return直接返回jsx一点问题都没有,我们项目里面从3.0一开始就一直在用了。去年11月份时候,我们技术选型时候就是因为uniapp不能写jsx才没有选的uniapp,我们原有项目太多jsx的东西了,迁移贼麻烦。 |
@hyccpq 如果用 jsx 写,是不是编译不了 h5? |
|
老哥, 我用的2.x的vue, 配置了babel-plugin-jsx, 但是会报编译错误 这是我的配置: const plugins = ["@vue/babel-plugin-jsx"]
if (process.env.UNI_OPT_TREESHAKINGNG) {
plugins.push(require('@dcloudio/vue-cli-plugin-uni-optimize/packages/babel-plugin-uni-api/index.js'))
}
if (
(
process.env.UNI_PLATFORM === 'app-plus' &&
process.env.UNI_USING_V8
) ||
(
process.env.UNI_PLATFORM === 'h5' &&
process.env.UNI_H5_BROWSER === 'builtin'
)
) {
const path = require('path')
const isWin = /^win/.test(process.platform)
const normalizePath = path => (isWin ? path.replace(/\\/g, '/') : path)
const input = normalizePath(process.env.UNI_INPUT_DIR)
try {
plugins.push([
require('@dcloudio/vue-cli-plugin-hbuilderx/packages/babel-plugin-console'),
{
file (file) {
file = normalizePath(file)
if (file.indexOf(input) === 0) {
return path.relative(input, file)
}
return false
}
}
])
} catch (e) {}
}
process.UNI_LIBRARIES = process.UNI_LIBRARIES || ['@dcloudio/uni-ui']
process.UNI_LIBRARIES.forEach(libraryName => {
plugins.push([
'import',
{
'libraryName': libraryName,
'customName': (name) => {
return `${libraryName}/lib/${name}/${name}`
}
}
])
})
module.exports = {
presets: [
[
'@vue/app',
{
modules: 'commonjs',
useBuiltIns: process.env.UNI_PLATFORM === 'h5' ? 'usage' : 'entry'
}
],
// * jsx插件合集
["@vue/babel-preset-jsx", { compositionAPI: true }],
],
plugins
} 我使用了'@vue/composition-api', 开了compositionAPI, 这个是正常的, 但是都不能在render函数中返回一段jsx, 只要有就会报错, 并不是直接的jsx文件, 就是一个.vue文件内, 而且是用的optionsAPI |
@Lisheri 他说的是隔壁那个,uniapp 不支持 jsx |
我在 babel 中添加可选链插件 @babel/plugin-proposal-optional-chaining,打包后依然报错提醒我安装 @babel/plugin-proposal-optional-chaining,请问 uni-app 里需要怎么处理 |
是的, 我发现了, 还有很多和vue不一样的地方 |
App,H5 平台可以支持jsx,tsx |
在某些特殊情况下jsx的形式要比普通的vue模板要更好,也更可控
隔壁taro都已经支持vue3 jsx了,希望官方能尽快支持jsx
The text was updated successfully, but these errors were encountered: