我在调试我的 preact 项目时遇到了一些问题,大多数 js 错误都没有出现在控制台中。例如,我将这段代码添加到我的组件中:<button onClick={() => { const someVar = someUnknownVariable;}}> fire error</button>当我点击按钮时,没有出现错误,说 someUnknownVariable is not defined,其他 js 错误也没有出现。这是我的 preact.config.js 文件:import compose from 'lodash.compose';export default (config, env, helpers) => { return compose(addEmotionPlugin, configRules)(config, env, helpers);};function addEmotionPlugin(config) { let babel = config.module.rules.filter(loader => loader.loader === 'babel-loader')[0] .options; babel.plugins.push([ 'emotion', { hoist: true, sourceMap: false, autoLabel: true, labelFormat: '[local]', extractStatic: false, outputDir: '', }, ]); return config;}function configRules(config, env) { if (env.isProd) { config.devtool = 'source-map'; config.output.filename = '[name].js'; config.output.publicPath = process.env.NODE_ASSETS || '/'; } return config;}在我的 index.js 文件中,我在开头有这段代码。if (process.env.NODE_ENV==='development') { require("preact/debug");}这是在我升级 preact 版本后发生的,请提供任何帮助。
1 回答

梦里花落0921
TA贡献1772条经验 获得超6个赞
问题出在旧的 eventListener 上,错误window.addEventListener('error', function(event) {});
导致预调试问题,当我删除它时,问题就解决了
添加回答
举报
0/150
提交
取消