當(dāng)我導(dǎo)入一個(gè).md文件時(shí),它給了我一個(gè)錯(cuò)誤,說它無法讀取這個(gè)特定.md file syntax的,我知道需要某種加載器來解析導(dǎo)入,但是當(dāng)我在網(wǎng)上查看時(shí),有一個(gè)加載器叫做'markdown-loader'它只用于markednpm 包。我正在使用react-markdown包來讀取 md 文件/* eslint-disable react/prefer-stateless-function */import React, { Component } from 'react';import ReactMarkdown from 'react-markdown';import AppMarkdown from './posts/sample.md';// import PropTypes from 'prop-types';class CardDetails extends Component { constructor() { super(); this.state = { markdown: '' }; } componentDidMount() { // Get the contents from the Markdown file and put them in the React state, so we can reference it in render() below. fetch(AppMarkdown) .then(res => res.text()) .then(text => this.setState({ markdown: text })); } render() { const { markdown } = this.state; return <ReactMarkdown source={markdown} />; }}CardDetails.propTypes = {};export default CardDetails;這是我的降價(jià)內(nèi)容sample.md# React & Markdown App- Benefits of using React... but...- Write layout in Markdown!我找不到包,我到處找,你知道裝載機(jī)嗎?謝謝
用于“react-markdown”npm庫的.md文件導(dǎo)入的Webpack加載器?
慕斯709654
2022-10-21 17:25:09