相关平台
微信小程序
复现仓库
https://github.com/Constantine-Marx/taroissue.git
小程序基础库: 2.32.1
使用框架: React
复现步骤
点击src/index/index.jsx
输入npm run dev:weapp
在微信开发者工具打开相应目录,并且运行
出现搜索栏但是点击无反应,onActionclick函数也没反应
期望结果
点击后有反应,右侧按钮滑出
实际结果
无反应,或直接不出现搜索栏,报错
页面【pages/index/index]错误:
TypeError: Super expression must either be null or a function
at _inherits (.node_modules@babel_runtime_helpers_esm_inherits.js:4)
at ._src_pages_index_index.jsx:3
at Object../node_modules/babel-loader/lib/index.js??ruleSet[1].rules[5].use[0]!./src/pages/index/index.jsx (._src_pages_index_index.jsx:22)
at webpack_require (webpack_bootstrap:19)
at Object../src/pages/index/index.jsx (._src_pages_index_index.jsx:22)
at webpack_require (webpack_bootstrap:19)
at webpack_exec (.node_modules@babel_runtime_helpers_esm_typeof.js:9)
at .node_modules@babel_runtime_helpers_esm_typeof.js:9
at Function.webpack_require.O (webpack_runtime_chunk loaded:25)
at .node_modules@babel_runtime_helpers_esm_typeof.js:9(env: Windows,mp,1.06.2303220; lib: 2.32.1)
环境信息
👽 Taro v3.6.7
Taro CLI 3.6.7 environment info:
System:
OS: Windows 10 10.0.22000
Binaries:
Node: 16.16.0 - C:\Program Files\nodejs\node.EXE
Yarn: 1.22.19 - ~\AppData\Roaming\npm\yarn.CMD
npm: 9.6.7 - C:\Program Files\nodejs\npm.CMD
npmPackages:
@tarojs/cli: 3.6.7 => 3.6.7
@tarojs/components: 3.6.7 => 3.6.7
@tarojs/helper: 3.6.7 => 3.6.7
@tarojs/plugin-framework-react: 3.6.7 => 3.6.7
@tarojs/plugin-platform-alipay: 3.6.7 => 3.6.7
@tarojs/plugin-platform-h5: 3.6.7 => 3.6.7
@tarojs/plugin-platform-jd: 3.6.7 => 3.6.7
@tarojs/plugin-platform-qq: 3.6.7 => 3.6.7
@tarojs/plugin-platform-swan: 3.6.7 => 3.6.7
@tarojs/plugin-platform-tt: 3.6.7 => 3.6.7
@tarojs/plugin-platform-weapp: 3.6.7 => 3.6.7
@tarojs/react: 3.6.7 => 3.6.7
@tarojs/runtime: 3.6.7 => 3.6.7
@tarojs/shared: 3.6.7 => 3.6.7
@tarojs/taro: 3.6.7 => 3.6.7
@tarojs/webpack5-runner: 3.6.7 => 3.6.7
babel-preset-taro: 3.6.7 => 3.6.7
eslint-config-taro: 3.6.7 => 3.6.7
react: ^18.0.0 => 18.2.0
react-native: ^0.71.8 => 0.71.8
taro-ui: ^3.1.0-beta.5 => 3.1.0-beta.5
补充信息
重装微信开发者工具,并且新建了一个taro项目后成功运行过一次,但后来运行其他文件时又不行了
这个报错通常是因为使用了低版本的taro-ui导致的。
请确保已经使用了taro-ui的最新版本(目前是2.3.0),并且在编译之前执行了npm install命令以确保所有依赖库都已正确安装。
如果问题仍然存在,请检查您的代码并确保没有使用ES6 class语法或其他不支持的语言特性。如果您的代码中存在这些语言特性,则需要使用相应的转换器进行转换。
根据报错信息,可能是由于使用了错误的继承方式导致的。建议检查代码中是否存在类似以下的错误写法:
class MyComponent extends React.Component {
constructor(props) {
super(props);
}
}
应该改为:
class MyComponent extends React.Component {
constructor(props) {
super(props);
}
}
如果还是无法解决问题,可以尝试升级 Taro 和相关依赖的版本,或者在 Taro 官方社区中提问,寻求更多的帮助。
可能是是taro-ui默认安装的版本和taro默认安装的版本不兼容,要指定npm i taro-ui@3.0.0-alpha.10
TypeError: Super expression must either be null or a function这个错误发生的原因很大可能是,taro-ui的版本跟taro版本没有兼容,可以考虑更换版本看看
npm i —save taro-ui@next
Taro 版本不兼容。检查开发项目时使用的Taro 版本和在编译时所使用的 Taro 版本是否一致,或者依赖库的版本是否匹配
问题可能出现在你使用的 Taro 版本与 React 版本不兼容导致的。根据错误信息,Super expression must either be null or a function,它通常与继承相关的代码有关。
为了解决这个问题,你可以尝试以下步骤:
更新 Taro 版本 检查 React 版本 清除缓存 检查代码
这个错误通常是由于组件的父类(即超类)没有正确地被继承所引起的。您可以尝试以下步骤来解决此问题:
1、确保您的 Taro-ui 组件已正确安装并导入。
2、检查组件的必要属性和方法是否都已被正确实现。例如,检查 render 方法是否返回了一个有效的 JSX 元素等。
3、确保您的 react 和 taro 版本是最新的,并且兼容。
4、如果仍然无法解决问题,请考虑更换其他类似的组件库或自行编写对应功能的组件。
同时,在开发者工具中也可点击报错信息跳转到源代码位置,进一步确认哪里出了错。
这个错误通常是由于编译工具没有正确处理ES6类的继承关系导致的。对于这个问题,您可以尝试以下的解决方案:
确保您的编译工具支持ES6语法。例如,在使用taro开发小程序时,官方推荐使用最新的Node.js版本和最新版的taro-cli。
确保您已经正常安装了taro-ui,并正确引入了SearchBar组件。可以在页面的config文件中添加需要使用的taro-ui组件,例如:
{
"usingComponents": {
"search-bar": "taro-ui/dist/weapp/form/search-bar"
}
}
import { SearchBar } from 'taro-ui';
import 'taro-ui/dist/style/components/search-bar.scss';
class MyPage extends Component {
render() {
return (
<ScrollView>
<SearchBar placeholder="搜索" />
</ScrollView>
)
}
}
如果您按照上述步骤进行了操作,仍然无法解决问题,请考虑更新您的taro、taro-ui版本,或提交一个issue到官方的GitHub仓库上,以获取更多帮助。