1 Star 2 Fork 2

自然框架项目 / vue3-cnd_用CDN的方式构建项目

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
index.html 1.45 KB
一键复制 编辑 原始数据 按行查看 历史
% 提交于 2022-04-20 21:02 . 跳转
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" href="/nfwt.ico" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>vue3 + CDN </title>
<script type="text/javascript">
// 假定 src在网站根目录
let basrUrl = '/'
// 判断所处网站,确定基础url
switch (window.location.origin) {
case 'https://naturefwvue.github.io': //github
case 'https://naturefw-project.gitee.io': //gitee
basrUrl = '/vue3-cnd/'
break
}
// 判断是否刷新的情况
const url = window.location.href
const paths = url.split('/')
// 查找标记
const flag = {
kind: '',
url: '',
index: 0
}
paths.forEach((item, index) => {
if (item.includes('cdn')){
flag.index = index
flag.kind = item
flag.url = url.replace(paths.splice(0, index + 1 ).join('/'), '').replace('/','')
}
})
console.log(flag)
if (flag.kind) {
// 跳回去
window.location.href = `${basrUrl}${flag.kind}?url=${flag.url}` //
}
</script>
</head>
<body>
<div id="app">
<a href="cdn1" >简单的演示</a> <br>
<br>
<a href="cdn2" >import的方式</a> <br>
<br>
<a href="cdn3" >仿工程化</a> <br>
<br>
<a href="cdn4" >二次封装</a> <br>
</div>
</body>
</html>
1
https://gitee.com/naturefw-project/vue3-cnd.git
git@gitee.com:naturefw-project/vue3-cnd.git
naturefw-project
vue3-cnd
vue3-cnd_用CDN的方式构建项目
master

搜索帮助