當我導入一個.md文件時,它給了我一個錯誤,說它無法讀取這個特定.md file syntax的,我知道需要某種加載器來解析導入,但是當我在網上查看時,有一個加載器叫做'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;這是我的降價內容sample.md# React & Markdown App- Benefits of using React... but...- Write layout in Markdown!我找不到包,我到處找,你知道裝載機嗎?謝謝
用于“react-markdown”npm庫的.md文件導入的Webpack加載器?
慕斯709654
2022-10-21 17:25:09