增加图标案例

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) { 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')); })(document.querySelector('script[src][type=module]:last-child'));
;(async () => { ;(async () => {
@ -10,7 +11,7 @@ window.appRoot = (function (script) {
less: less less: less
}, },
getFile(url) { getFile(url) {
if (!/^(https?:)?\/\//.test(url)) { if (!(/^(https?:)?\/\//)) {
url = (appRoot + url).replace(/\/+.?\/+/g, '/'); url = (appRoot + url).replace(/\/+.?\/+/g, '/');
} }
return fetch(url).then(res => { return fetch(url).then(res => {
@ -88,6 +89,10 @@ window.appRoot = (function (script) {
const icons = await loadVue("/static/plugs/core/vue.element.icons.js"); const icons = await loadVue("/static/plugs/core/vue.element.icons.js");
for (let i in icons) app.component(i, icons[i]); 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); app.use(router).use(ElementPlus).mount(document.body);
})().catch(function (ex) { })().catch(function (ex) {

View File

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