如何将html文件导入Vue文件
我有一些html文件,其中包含一些图表,我必须在mu vue页面中显示这些图表。 但是,当我尝试导入它们时,会出现以下错误:如何将html文件导入Vue文件,html,vue.js,import,Html,Vue.js,Import,我有一些html文件,其中包含一些图表,我必须在mu vue页面中显示这些图表。 但是,当我尝试导入它们时,会出现以下错误: ./src/components/graphs/myHtml_js.html 2:0 Module parse failed: Unexpected token (2:0) You may need an appropriate loader to handle this file type, currently no loaders are configured to
./src/components/graphs/myHtml_js.html 2:0
Module parse failed: Unexpected token (2:0)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
|
> <!doctype html>
| <html lang="en">
| <head>
/src/components/graphs/myHtml\u js.html 2:0
模块分析失败:意外令牌(2:0)
您可能需要适当的加载程序来处理此文件类型,目前没有配置加载程序来处理此文件。看见https://webpack.js.org/concepts#loaders
|
>
|
|
我尝试使用v-html,但显示了相同的错误
以下是我尝试导入它的方式:
<template>
<v-main>
<v-container>
<v-row align='center' justify="center">
<v-col
class="d-flex justify-center"
cols="6"
>
<v-card
class="mx-auto"
width="100%"
min-height="200px"
outlined
>
<htmlImport />
</v-card>
</v-col>
</v-row>
</v-container>
</v-main>
</template>
<script>
import { htmlImport } from '@/components/graphs/myHtml_js.html'
export default {
component: {
htmlImport
},
data: () => ({
}),
methods: {
}
};
</script>
从“@/components/graphs/myHtml_js.html”导入{htmlImport}
导出默认值{
组成部分:{
htmlImport
},
数据:()=>({
}),
方法:{
}
};
您需要在网页包/vue配置中添加html加载程序。然后,您将能够将html作为变量导入。或者,您可以获取html(例如使用axios),然后根据需要使用响应