增加图标案例

This commit is contained in:
Anyon 2021-12-13 18:19:49 +08:00
parent 8af7440af4
commit 3fd599a860
2 changed files with 19 additions and 14 deletions

View File

@ -1,6 +1,7 @@
/*! 项目应用根路径 */
window.appRoot = (function (script) {
return '/' + script.src.split('/').slice(3, -2).join('/') + '/';
let src = script.src.split('/').slice(3);
return src.pop(), src.pop(), '/' + src.join('/') + '/';
})(document.querySelector('script[src][type=module]:last-child'));
;(async () => {
@ -10,7 +11,7 @@ window.appRoot = (function (script) {
less: less
},
getFile(url) {
if (!/^(https?:)?\/\//.test(url)) {
if (!(/^(https?:)?\/\//)) {
url = (appRoot + url).replace(/\/+.?\/+/g, '/');
}
return fetch(url).then(res => {
@ -88,6 +89,10 @@ window.appRoot = (function (script) {
const icons = await loadVue("/static/plugs/core/vue.element.icons.js");
for (let i in icons) app.component(i, icons[i]);
// 全局字体文件
// const icons = await loadVue("https://unpkg.com/@element-plus/icons@0.0.11/lib/index.js");
// for (let i in icons) app.component(i, icons[i]);
app.use(router).use(ElementPlus).mount(document.body);
})().catch(function (ex) {

View File

@ -49,9 +49,9 @@
<el-menu :default-active="1" :open="1">
<el-sub-menu index="1">
<template #title>
<!--<el-icon>-->
<!--<location></location>-->
<!--</el-icon>-->
<el-icon>
<location></location>
</el-icon>
<span>Navigator One</span>
</template>
@ -61,21 +61,21 @@
</el-sub-menu>
<el-menu-item index="2" data-route="/static/template/pages/two.vue">
<!--<el-icon>-->
<!--<icon-menu></icon-menu>-->
<!--</el-icon>-->
<el-icon>
<aim></aim>
</el-icon>
<span>Navigator Two</span>
</el-menu-item>
<el-menu-item index="3" data-route="/static/template/pages/thr.vue">
<!--<el-icon>-->
<!--<document></document>-->
<!--</el-icon>-->
<el-icon>
<document></document>
</el-icon>
<span>Navigator Three</span>
</el-menu-item>
<el-menu-item index="4" data-route="/static/template/pages/four.vue">
<!--<el-icon>-->
<!--<setting></setting>-->
<!--</el-icon>-->
<el-icon>
<setting></setting>
</el-icon>
<span>Navigator Four</span>
</el-menu-item>
</el-menu>