How to import a .txt file from my source?

前端 未结 4 1170
耶瑟儿~
耶瑟儿~ 2020-12-11 14:28

I try to import a .txt file to show the text in a text box.

My code:

import React, { Component } from \'react\';
import \'./LoadMyFile.css\';
import          


        
4条回答
  •  [愿得一人]
    2020-12-11 15:24

    I converted the text to base64 and then decoded it.

    const base64textfile ="Asdfsdfsf";
    export default base64textfile ;
    
    
    import { base64decode } from "nodejs-base64";
    var decodedText = base64decode(base64textfile);
    

提交回复
热议问题