我想用ParcelJS作为字符串导入HTML文件,如下所示:
import testHTML from './testHTML.html';
document.body.insertAdjacentHTML('afterbegin', testHTML);但医生说:
在JavaScript中导入HTML并不静态地包含HTML字符串,但是将使用Fetch API动态地获取HTML文件。
是否有任何方法将导入强制为字符串?
发布于 2022-05-02 10:01:01
从‘bundle-text:./index.pug’导入html;document.body.innerHTML = html;
所以html也很好
没有任何配置
import html from 'bundle-text:./index.html';
document.body.innerHTML = html;打字稿修正ts(2307)
就像"*.vue“
// index.d.ts
declare module 'bundle-text:*' {
const s: string
export default s
}https://stackoverflow.com/questions/67308101
复制相似问题