如何获取一个没有双引号的翡翠文件?

问题描述 投票:1回答:1
  • 我想在fetch中使用玉石文件。
  • 在写jade文件时,会插入双引号,浏览器会将其识别为文本。
  • 如果我用'home.html'代替'home.jade',就可以了。

view.jade

doctype html
    html
    meta(charset='utf-8')
    style
        include view.css
    script
        include ../fetch/fetch.js
body
    header

    section
        nav

        main(id='view')

家玉

div(id='main_image')
    input(type='image' class='leftbtn' src='/leftbtn.png')
    input(type='image' class='rightbtn' src='/rightbtn.png')    
p(class='main_p') sth
div(class='wrap_item')

fetch.js

fetch('home.jade').then((res)=>{
    res.text().then((text)=>{
        document.querySelector('#view').innerHTML = text;
    });
});
javascript fetch pug
1个回答
0
投票

Jade代码不能被浏览器理解,这就是为什么它被转换为HTML。你应该取回home.html,因为那才是浏览器真正能理解的代码。

© www.soinside.com 2019 - 2024. All rights reserved.