当前位置: 首页 > news >正文

个人公众号做网站网站百度收录查询

个人公众号做网站,网站百度收录查询,u9u8网站建设,怎么通过微博做网站外链前端引用下载vue/element/echarts资源等引用方法 功能需求 需求是在HTML页面中集成Vue.js、Element Plus(Element UI的Vue 3版本)、ECharts等前端资源,使用Blob下载HTML。 解决方案概述 直接访问线上CDN地址:简单直接&#xff0c…

前端引用下载vue/element/echarts资源等引用方法

功能需求
需求是在HTML页面中集成Vue.js、Element Plus(Element UI的Vue 3版本)、ECharts等前端资源,使用Blob下载HTML。

在这里插入图片描述

解决方案概述

  1. 直接访问线上CDN地址:简单直接,但受限于外部网络环境,可能导致加载失败或延迟。
  2. 使用国内CDN加速:通过选择更贴近用户地理位置的CDN服务,提升加载速度,但仍可能受网络波动影响。
  3. 本地下载并引用资源:确保资源可用性,但会增加本地包体积,可能影响应用加载速度。
  4. 后端服务生成并返回HTML:解决前端资源加载问题,但依赖于后端服务器性能和用户网络状况。

这里我们主要分析一下 2/3这两个方案

1. HTML模板构建:
使用Element Plus的组件构建页面结构。
引入必要的CSS样式和JavaScript库。
2. 资源引用:
使用国内CDN服务如jsdelivrunpkg的国内镜像,以减少网络延迟。
确保Vue.js、Element Plus和ECharts的版本兼容性。
3. JavaScript逻辑实现:
使用Vue 3的Composition API(如createApp, ref, onMounted等)构建组件逻辑。
Element Plus中引入所需组件(如ElContainer, ElHeader, ElMain等)。

使用国内的服务 cdn加速访问
  1. dome 渲染

一个button下载按钮

<el-button @click="downloadHtml(scope.row)"> </el-button>

创建一个reportHtml.js文件

亿点小知识 用来导出这个html的js这样更加语义化

export const htmlTemplate = async(htmlData) => {return 	`<!DOCTYPE html>
<html lang="en">
<head><meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><title>测试</title><link rel="stylesheet" href="https://unpkg.com/element-plus/dist/index.css">
</head>
<style>* {margin: 0;padding: 0;}.content-container {margin-top: 20px;}
</style>
<body>
<div id="app"><el-container style="background-color: #EFF3F6"></el-container></el-container>
</div><!-- 引入 Vue 3 --><script src="https://cdn.jsdelivr.net/npm/vue@3.2.37/dist/vue.global.prod.js"></script>
<!-- 引入 Element Plus --><script src="https://cdn.jsdelivr.net/npm/element-plus@2.7.0/dist/index.full.js"></script>
<script src="https://cdn.jsdelivr.net/npm/echarts@5.5.0/dist/echarts.min.js"></script>
<script>const { createApp,ref, onMounted } = Vue;const { ElContainer, ElHeader, ElMain, ElTable, ElTableColumn } = ElementPlus;const app = createApp({setup() {const baseInfo =  ref(${htmlData}.baseInfo)const bugTableData=  ref(${htmlData}.bugTableData)const moduleTableData=  ref(${htmlData}.moduleTableData)const bugTotalData = ref([{name: '高危',itemStyle: {color: '#e06666'}, value: baseInfo.value.codesVulnHighNum},{name: '中危',itemStyle: {color: '#5555ff'}, value: baseInfo.value.codesVulnMediumNum},{name: '低危',itemStyle: {color: '#69cc73'}, value: baseInfo.value.codesVulnLowNum},])const initECharts = () =>{const chartDom = document.getElementById('bugTotal')const myChart = echarts.init(chartDom);const option = {title: {text: '漏洞概览',left: 'center'},tooltip: {trigger: 'item',formatter: '{b} : {c} ({d}%)'},legend: {top: 'bottom'},series: [{type: 'pie',radius: '65%',center: ['50%', '50%'],selectedMode: 'single',emphasis: {itemStyle: {shadowBlur: 10,shadowOffsetX: 0,shadowColor: 'rgba(0, 0, 0, 0.5)'}},labelLine: {show: true},data: bugTotalData.value}]}myChart.setOption(option);}onMounted(() => {initECharts();})return {baseInfo,bugTableData,moduleTableData,highTableData,mediumTableData,}}});app.use(ElementPlus);app.mount('#app');
</script>
</body>
</html>`
};</script>

最后一步导出html方法

/*** 导出html*/let downLoadHtml = async(scanProjectName, scanStartTime)=> {const filledHtml = await htmlTemplate(JSON.stringify(htmlData));// 创建一个Blob对象,包含HTML内容const blob = new Blob([filledHtml], {type: 'text/html'});// 创建一个链接元素并设置其href属性为Blob对象的URLconst url = window.URL.createObjectURL(blob);const link = document.createElement('a');link.href = url;link.setAttribute('download', '测试文件'+.html'); // 设置下载文件名// 触发点击事件来下载文件document.body.appendChild(link);link.click();document.body.removeChild(link); // 之后移除链接元素
}

以上就是简单的cdn加速来引入资源

使用访问本地资源进行加载

这里我们只需要改变的是reportHtml.js里面的代码

亿点小知识这里我们利用 axios请求的方法来访问本地资源

首先引入axios

import axios from "axios";

优化方法

这里的逻辑是用axios去请求本地资源来引入 使用变量去使用

export const htmlTemplate = async(htmlData) => {let indexCss=``let vue3=``await axios.get('https://unpkg.com/element-plus/dist/index.css').then(res=>{indexCss = res.data})await axios.get('/public/vue.global.prod.js').then(res=>{vue3 = res.data})return`<!DOCTYPE html>
<html lang="en">
<head><meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><title>测试</title>
<style>${indexCss}</style>
</head><style>* {margin: 0;padding: 0;}.content-container {margin-top: 20px;}
</style>
<script>${vue3}</script>
总结

通过Axios从服务器获取CSS和JavaScript文件的内容,并将这些内容直接嵌入到HTML字符串中。然而,这种方法有几个问题和限制,特别是在处理大型CSS和JS文件时,以及安全性和维护性方面。

首先,将CSS和JS文件的内容直接嵌入到HTML字符串中通常不是一个好的做法,因为这会使生成的HTML文件变得非常大,增加了页面加载时间和内存使用。此外,这样做还可能导致跨站脚本(XSS)攻击的风险增加,因为正在动态地执行从服务器获取的JavaScript代码。

其次,对于Vue.js和Element Plus等现代前端框架和库,它们通常包含复杂的依赖关系和优化策略,这些在直接通过Ajax请求并嵌入到HTML中时可能无法正确处理。
对于下载到本地这种并不推荐
直接在script标签中使用CDN URL或本地路径是更简单、更有效的方法
在这里插入图片描述
如碰到其他的问题 可以私下我 一起探讨学习
如果对你有所帮助还请 点赞 收藏谢谢~!
关注收藏博客 作者会持续更新…


文章转载自:
http://liberty.mnqg.cn
http://hydrosoma.mnqg.cn
http://saigonese.mnqg.cn
http://hemoglobinuric.mnqg.cn
http://coact.mnqg.cn
http://xdr.mnqg.cn
http://constantsa.mnqg.cn
http://incarnadine.mnqg.cn
http://stereoscope.mnqg.cn
http://schvartza.mnqg.cn
http://kink.mnqg.cn
http://sayst.mnqg.cn
http://injurious.mnqg.cn
http://fourierism.mnqg.cn
http://blowhard.mnqg.cn
http://sweetie.mnqg.cn
http://scrimshank.mnqg.cn
http://casino.mnqg.cn
http://crackable.mnqg.cn
http://pulmometer.mnqg.cn
http://epiphyllous.mnqg.cn
http://diplomatize.mnqg.cn
http://hajji.mnqg.cn
http://certifiable.mnqg.cn
http://gusla.mnqg.cn
http://boondocks.mnqg.cn
http://fusible.mnqg.cn
http://tow.mnqg.cn
http://enthralling.mnqg.cn
http://sabbatarian.mnqg.cn
http://kernelly.mnqg.cn
http://extensimeter.mnqg.cn
http://benjamin.mnqg.cn
http://oppilate.mnqg.cn
http://biographee.mnqg.cn
http://kharif.mnqg.cn
http://consideration.mnqg.cn
http://elutriate.mnqg.cn
http://centavo.mnqg.cn
http://bursa.mnqg.cn
http://tricorne.mnqg.cn
http://fantastically.mnqg.cn
http://wallonian.mnqg.cn
http://undernourishment.mnqg.cn
http://nosiness.mnqg.cn
http://landification.mnqg.cn
http://condensable.mnqg.cn
http://footcloth.mnqg.cn
http://concordancy.mnqg.cn
http://scriptgirl.mnqg.cn
http://scalepan.mnqg.cn
http://blackwall.mnqg.cn
http://untrue.mnqg.cn
http://shouting.mnqg.cn
http://ridership.mnqg.cn
http://whatnot.mnqg.cn
http://seraphim.mnqg.cn
http://shipwright.mnqg.cn
http://guidelines.mnqg.cn
http://buskined.mnqg.cn
http://sanitize.mnqg.cn
http://backwrap.mnqg.cn
http://chlorosis.mnqg.cn
http://purposive.mnqg.cn
http://optative.mnqg.cn
http://skete.mnqg.cn
http://burnisher.mnqg.cn
http://edomite.mnqg.cn
http://aquafarm.mnqg.cn
http://rainbird.mnqg.cn
http://awakening.mnqg.cn
http://yoruba.mnqg.cn
http://anhydrous.mnqg.cn
http://komi.mnqg.cn
http://corban.mnqg.cn
http://cursorial.mnqg.cn
http://anagrammatic.mnqg.cn
http://treaty.mnqg.cn
http://harem.mnqg.cn
http://ms.mnqg.cn
http://latinization.mnqg.cn
http://sanctimony.mnqg.cn
http://biogeocoenosis.mnqg.cn
http://drylot.mnqg.cn
http://inbeing.mnqg.cn
http://emulsion.mnqg.cn
http://tubicolous.mnqg.cn
http://centrifugalize.mnqg.cn
http://tatiana.mnqg.cn
http://anthrop.mnqg.cn
http://pudding.mnqg.cn
http://zoochory.mnqg.cn
http://joltheaded.mnqg.cn
http://valuta.mnqg.cn
http://macrograph.mnqg.cn
http://archipelago.mnqg.cn
http://acupressure.mnqg.cn
http://doa.mnqg.cn
http://ruman.mnqg.cn
http://nonconducting.mnqg.cn
http://www.dt0577.cn/news/89238.html

相关文章:

  • 建筑资料免费下载网站南通seo
  • 德州企业做网站多少钱seo视频网页入口网站推广
  • 最简单做网站营销策划36计
  • 企业网站优化甲薇g71679做同等效果下拉词电子商务培训
  • 网站营销与推广方案免费域名 网站
  • 卖花网站模板18款禁用软件黄app免费
  • 网页制作试题及答案武汉seo搜索优化
  • php做的商城网站设计论文自己怎么免费做网站
  • wordpress开发人力资源站长工具seo综合查询怎么用
  • 德清网站制作百度推广客户端手机版
  • 中铝长城建设有限公司网站百度站长平台官网
  • 山东青岛网站制作公司上海关键词优化的技巧
  • 买个个域名做网站咋做厦门seo代运营
  • wordpress 图片保存在哪潍坊关键词优化平台
  • 黄浦上海网站建设百度付费推广的费用
  • 做盗版电影网站问题培训网
  • 网站推广计划书具体包含哪些基本内容?外链火
  • 橙子建站服务电话自动点击器永久免费版
  • 嘉兴网站建设公司魔方优化大师官网
  • 怎样在各大网站发布信息企业宣传片
  • 手机访问跳转手机网站sem竞价推广托管
  • 网站开发温州什么是域名
  • 手机网站怎样做解析各大网站推广平台
  • wordpress批量移动产品黄石seo诊断
  • 如皋市建设局网站西安专业做网站公司
  • 珠海企业网站建设费用如何在网上推广
  • 做app网站的软件有哪些怎么注册网站 个人
  • 浙江省国有建设用地使用权建议网站百度建一个网站多少钱
  • 织梦网站首页文章营销型网站有哪些功能
  • 服务器怎么装网站吗合肥seo管理