【发布时间】:2017-03-02 12:00:51
【问题描述】:
我将 html 字符串从后端传递给 react 组件,我使用 react-html-parser 将我的 html 字符串转换为 react 组件。但出现错误。
./~/entities/maps/entities.json 中的错误 模块解析失败:/Users/PrashantKumarKatariya/teabox_web/teabox_django/static/node_modules/entities/maps/entities.json 意外令牌 (1:9) 您可能需要适当的加载程序来处理此文件类型。 SyntaxError:意外的令牌 (1:9) 在 Parser.pp$4.raise (/Users/PrashantKumarKatariya/teabox_web/teabox_django/static/node_modules/acorn/dist/acorn.js:2221:15) 在 Parser.pp.unexpected (/Users/PrashantKumarKatariya/teabox_web/teabox_django/static/node_modules/acorn/dist/acorn.js:603:10) 在 Parser.pp.semicolon (/Users/PrashantKumarKatariya/teabox_web/teabox_django/static/node_modules/acorn/dist/acorn.js:581:61) 在 Parser.pp$1.parseExpressionStatement (/Users/PrashantKumarKatariya/teabox_web/teabox_django/static/node_modules/acorn/dist/acorn.js:966:10) 在 Parser.pp$1.parseStatement (/Users/PrashantKumarKatariya/teabox_web/teabox_django/static/node_modules/acorn/dist/acorn.js:730:24) 在 Parser.pp$1.parseBlock (/Users/PrashantKumarKatariya/teabox_web/teabox_django/static/node_modules/acorn/dist/acorn.js:981:25) 在 Parser.pp$1.parseStatement (/Users/PrashantKumarKatariya/teabox_web/teabox_django/static/node_modules/acorn/dist/acorn.js:709:33) 在 Parser.pp$1.parseTopLevel (/Users/PrashantKumarKatariya/teabox_web/teabox_django/static/node_modules/acorn/dist/acorn.js:638:25) 在 Parser.parse (/Users/PrashantKumarKatariya/teabox_web/teabox_django/static/node_modules/acorn/dist/acorn.js:516:17) 在 Object.parse (/Users/PrashantKumarKatariya/teabox_web/teabox_django/static/node_modules/acorn/dist/acorn.js:3098:39) 在 Parser.parse (/Users/PrashantKumarKatariya/teabox_web/teabox_django/static/node_modules/webpack/lib/Parser.js:902:15) 在 DependenciesBlock。 (/Users/PrashantKumarKatariya/teabox_web/teabox_django/static/node_modules/webpack/lib/NormalModule.js:104:16) 在 DependenciesBlock.onModuleBuild (/Users/PrashantKumarKatariya/teabox_web/teabox_django/static/node_modules/webpack-core/lib/NormalModuleMixin.js:310:10) 在 nextLoader (/Users/PrashantKumarKatariya/teabox_web/teabox_django/static/node_modules/webpack-core/lib/NormalModuleMixin.js:275:25) 在 /Users/PrashantKumarKatariya/teabox_web/teabox_django/static/node_modules/webpack-core/lib/NormalModuleMixin.js:259:5 在 Storage.finished (/Users/PrashantKumarKatariya/teabox_web/teabox_django/static/node_modules/enhanced-resolve/lib/CachedInputFileSystem.js:38:16) 在 /Users/PrashantKumarKatariya/teabox_web/teabox_django/static/node_modules/graceful-fs/graceful-fs.js:78:16 在 FSReqWrap.readFileAfterClose [as oncomplete] (fs.js:445:3) @ ./~/react-html-parser/~/htmlparser2/lib/Tokenizer.js 4:16-54
./~/entities/maps/legacy.json 中的错误 模块解析失败:/Users/PrashantKumarKatariya/teabox_web/teabox_django/static/node_modules/entities/maps/legacy.json 意外令牌 (1:9) 您可能需要适当的加载程序来处理此文件类型。 SyntaxError:意外的令牌 (1:9) 在 Parser.pp$4.raise (/Users/PrashantKumarKatariya/teabox_web/teabox_django/static/node_modules/acorn/dist/acorn.js:2221:15) 在 Parser.pp.unexpected (/Users/PrashantKumarKatariya/teabox_web/teabox_django/static/node_modules/acorn/dist/acorn.js:603:10) 在 Parser.pp.semicolon (/Users/PrashantKumarKatariya/teabox_web/teabox_django/static/node_modules/acorn/dist/acorn.js:581:61) 在 Parser.pp$1.parseExpressionStatement (/Users/PrashantKumarKatariya/teabox_web/teabox_django/static/node_modules/acorn/dist/acorn.js:966:10) 在 Parser.pp$1.parseStatement (/Users/PrashantKumarKatariya/teabox_web/teabox_django/static/node_modules/acorn/dist/acorn.js:730:24) 在 Parser.pp$1.parseBlock (/Users/PrashantKumarKatariya/teabox_web/teabox_django/static/node_modules/acorn/dist/acorn.js:981:25) 在 Parser.pp$1.parseStatement (/Users/PrashantKumarKatariya/teabox_web/teabox_django/static/node_modules/acorn/dist/acorn.js:709:33) 在 Parser.pp$1.parseTopLevel (/Users/PrashantKumarKatariya/teabox_web/teabox_django/static/node_modules/acorn/dist/acorn.js:638:25) 在 Parser.parse (/Users/PrashantKumarKatariya/teabox_web/teabox_django/static/node_modules/acorn/dist/acorn.js:516:17) 在 Object.parse (/Users/PrashantKumarKatariya/teabox_web/teabox_django/static/node_modules/acorn/dist/acorn.js:3098:39) 在 Parser.parse (/Users/PrashantKumarKatariya/teabox_web/teabox_django/static/node_modules/webpack/lib/Parser.js:902:15) 在 DependenciesBlock。 (/Users/PrashantKumarKatariya/teabox_web/teabox_django/static/node_modules/webpack/lib/NormalModule.js:104:16) 在 DependenciesBlock.onModuleBuild (/Users/PrashantKumarKatariya/teabox_web/teabox_django/static/node_modules/webpack-core/lib/NormalModuleMixin.js:310:10) 在 nextLoader (/Users/PrashantKumarKatariya/teabox_web/teabox_django/static/node_modules/webpack-core/lib/NormalModuleMixin.js:275:25) 在 /Users/PrashantKumarKatariya/teabox_web/teabox_django/static/node_modules/webpack-core/lib/NormalModuleMixin.js:259:5 在 Storage.finished (/Users/PrashantKumarKatariya/teabox_web/teabox_django/static/node_modules/enhanced-resolve/lib/CachedInputFileSystem.js:38:16) 在 /Users/PrashantKumarKatariya/teabox_web/teabox_django/static/node_modules/graceful-fs/graceful-fs.js:78:16 在 FSReqWrap.readFileAfterClose [as oncomplete] (fs.js:445:3) @ ./~/react-html-parser/~/htmlparser2/lib/Tokenizer.js 5:16-52
./~/entities/maps/xml.json 中的错误 模块解析失败:/Users/PrashantKumarKatariya/teabox_web/teabox_django/static/node_modules/entities/maps/xml.json 意外令牌 (1:6) 您可能需要适当的加载程序来处理此文件类型。 SyntaxError:意外的令牌 (1:6) 在 Parser.pp$4.raise (/Users/PrashantKumarKatariya/teabox_web/teabox_django/static/node_modules/acorn/dist/acorn.js:2221:15) 在 Parser.pp.unexpected (/Users/PrashantKumarKatariya/teabox_web/teabox_django/static/node_modules/acorn/dist/acorn.js:603:10) 在 Parser.pp.semicolon (/Users/PrashantKumarKatariya/teabox_web/teabox_django/static/node_modules/acorn/dist/acorn.js:581:61) 在 Parser.pp$1.parseExpressionStatement (/Users/PrashantKumarKatariya/teabox_web/teabox_django/static/node_modules/acorn/dist/acorn.js:966:10) 在 Parser.pp$1.parseStatement (/Users/PrashantKumarKatariya/teabox_web/teabox_django/static/node_modules/acorn/dist/acorn.js:730:24) 在 Parser.pp$1.parseBlock (/Users/PrashantKumarKatariya/teabox_web/teabox_django/static/node_modules/acorn/dist/acorn.js:981:25) 在 Parser.pp$1.parseStatement (/Users/PrashantKumarKatariya/teabox_web/teabox_django/static/node_modules/acorn/dist/acorn.js:709:33) 在 Parser.pp$1.parseTopLevel (/Users/PrashantKumarKatariya/teabox_web/teabox_django/static/node_modules/acorn/dist/acorn.js:638:25) 在 Parser.parse (/Users/PrashantKumarKatariya/teabox_web/teabox_django/static/node_modules/acorn/dist/acorn.js:516:17) 在 Object.parse (/Users/PrashantKumarKatariya/teabox_web/teabox_django/static/node_modules/acorn/dist/acorn.js:3098:39) 在 Parser.parse (/Users/PrashantKumarKatariya/teabox_web/teabox_django/static/node_modules/webpack/lib/Parser.js:902:15) 在 DependenciesBlock。 (/Users/PrashantKumarKatariya/teabox_web/teabox_django/static/node_modules/webpack/lib/NormalModule.js:104:16) 在 DependenciesBlock.onModuleBuild (/Users/PrashantKumarKatariya/teabox_web/teabox_django/static/node_modules/webpack-core/lib/NormalModuleMixin.js:310:10) 在 nextLoader (/Users/PrashantKumarKatariya/teabox_web/teabox_django/static/node_modules/webpack-core/lib/NormalModuleMixin.js:275:25) 在 /Users/PrashantKumarKatariya/teabox_web/teabox_django/static/node_modules/webpack-core/lib/NormalModuleMixin.js:259:5 在 Storage.finished (/Users/PrashantKumarKatariya/teabox_web/teabox_django/static/node_modules/enhanced-resolve/lib/CachedInputFileSystem.js:38:16) 在 /Users/PrashantKumarKatariya/teabox_web/teabox_django/static/node_modules/graceful-fs/graceful-fs.js:78:16 在 FSReqWrap.readFileAfterClose [as oncomplete] (fs.js:445:3) @ ./~/react-html-parser/~/htmlparser2/lib/Tokenizer.js 6:16-49
./~/entities/maps/decode.json 中的错误 模块解析失败:/Users/PrashantKumarKatariya/teabox_web/teabox_django/static/node_modules/entities/maps/decode.json 意外令牌 (1:4) 您可能需要适当的加载程序来处理此文件类型。 SyntaxError:意外的令牌 (1:4) 在 Parser.pp$4.raise (/Users/PrashantKumarKatariya/teabox_web/teabox_django/static/node_modules/acorn/dist/acorn.js:2221:15) 在 Parser.pp.unexpected (/Users/PrashantKumarKatariya/teabox_web/teabox_django/static/node_modules/acorn/dist/acorn.js:603:10) 在 Parser.pp.semicolon (/Users/PrashantKumarKatariya/teabox_web/teabox_django/static/node_modules/acorn/dist/acorn.js:581:61) 在 Parser.pp$1.parseExpressionStatement (/Users/PrashantKumarKatariya/teabox_web/teabox_django/static/node_modules/acorn/dist/acorn.js:966:10) 在 Parser.pp$1.parseStatement (/Users/PrashantKumarKatariya/teabox_web/teabox_django/static/node_modules/acorn/dist/acorn.js:730:24) 在 Parser.pp$1.parseBlock (/Users/PrashantKumarKatariya/teabox_web/teabox_django/static/node_modules/acorn/dist/acorn.js:981:25) 在 Parser.pp$1.parseStatement (/Users/PrashantKumarKatariya/teabox_web/teabox_django/static/node_modules/acorn/dist/acorn.js:709:33) 在 Parser.pp$1.parseTopLevel (/Users/PrashantKumarKatariya/teabox_web/teabox_django/static/node_modules/acorn/dist/acorn.js:638:25) 在 Parser.parse (/Users/PrashantKumarKatariya/teabox_web/teabox_django/static/node_modules/acorn/dist/acorn.js:516:17) 在 Object.parse (/Users/PrashantKumarKatariya/teabox_web/teabox_django/static/node_modules/acorn/dist/acorn.js:3098:39) 在 Parser.parse (/Users/PrashantKumarKatariya/teabox_web/teabox_django/static/node_modules/webpack/lib/Parser.js:902:15) 在 DependenciesBlock。 (/Users/PrashantKumarKatariya/teabox_web/teabox_django/static/node_modules/webpack/lib/NormalModule.js:104:16) 在 DependenciesBlock.onModuleBuild (/Users/PrashantKumarKatariya/teabox_web/teabox_django/static/node_modules/webpack-core/lib/NormalModuleMixin.js:310:10) 在 nextLoader (/Users/PrashantKumarKatariya/teabox_web/teabox_django/static/node_modules/webpack-core/lib/NormalModuleMixin.js:275:25) 在 /Users/PrashantKumarKatariya/teabox_web/teabox_django/static/node_modules/webpack-core/lib/NormalModuleMixin.js:259:5 在 Storage.finished (/Users/PrashantKumarKatariya/teabox_web/teabox_django/static/node_modules/enhanced-resolve/lib/CachedInputFileSystem.js:38:16) 在 /Users/PrashantKumarKatariya/teabox_web/teabox_django/static/node_modules/graceful-fs/graceful-fs.js:78:16 在 FSReqWrap.readFileAfterClose [as oncomplete] (fs.js:445:3) @ ./~/entities/lib/decode_codepoint.js 1:16-46
【问题讨论】:
标签: parsing reactjs html-parsing