我目前正试图在我的Vue.js页面中显示以HTML格式保存的本地图片。 我尝试使用以下行将HTML文件的内容加载到变量中:
computed: {
compiledHtml: function() {
return this.asset;
}
const path = 'http://localhost:5000/load_results'
axios
.get(path)
.then((res) => {
this.asset = res.data
})
然后我尝试使用v-html
显示它:
<div v-html="compiledHtml"></div>
它实际上与包含几行的简单HTML文件一起工作,例如:
<h1> test load HTML file </h1>
但是,我的图片大小是3.5Mb,比我给你的示例复杂得多,当我试图显示它时,它会给我一个空白
有人知道如何克服这个问题吗?谢谢
下面是我使用的GET方法:
@bp.route('/load_results', methods=['GET'])
def load():
f = codecs.open("./file.html", 'r', 'utf-8')
return f.read()
我通过修改GET方法在API中打开文件成功地解决了这个问题,如下所示:
因此,它会在我的webbrowser中的新选项卡中打开我的图像。 无论如何,谢谢你
相关问题 更多 >
编程相关推荐