我有一个HTML模板作为单独的文件,我想将其导入到我的React应用程序中。目的是替换特定关键字,然后将其作为邮件正文发送。
我该如何在我的React应用程序中导入此html文件?
我尝试过
我对两个尝试都收到了以下错误:
Module parse failed: Unexpected token (1:0) You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file.
实际上,这个问题归结为:如何在React中将文本文件作为字符串导入?这是一个经常回答的问题,所有结果似乎都要使用异步加载程序--这不应该发生,因为该文件在构建之前已经准备好了,位于我的src目录中。
我该如何在我的React应用程序中导入此html文件?
我尝试过
import htmlString from'../../../constants/EmailHTML.html';
,以及var html = require('../../../constants/EmailHTML.html');
(这在类似的问题中被建议)。我对两个尝试都收到了以下错误:
Module parse failed: Unexpected token (1:0) You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file.
实际上,这个问题归结为:如何在React中将文本文件作为字符串导入?这是一个经常回答的问题,所有结果似乎都要使用异步加载程序--这不应该发生,因为该文件在构建之前已经准备好了,位于我的src目录中。