自定义指令归类
This commit is contained in:
20
src/main.ts
20
src/main.ts
@@ -7,6 +7,7 @@ import 'normalize.css'
|
||||
import './assets/css/style.css'
|
||||
import SvgIcon from "@/components/SvgIcon/index.vue";
|
||||
import "virtual:svg-icons-register";
|
||||
import directives from "./directives/index.js";
|
||||
|
||||
import i18n from "./lang/index";
|
||||
import flexible from "./utils/flexible.js";
|
||||
@@ -17,32 +18,15 @@ import 'element-plus/dist/index.css'
|
||||
|
||||
import ignoredWarning from './ignoredWarning'
|
||||
|
||||
import vEllipsis from './utils/ellispsis'
|
||||
|
||||
|
||||
const app = createApp(App)
|
||||
ignoredWarning(app)
|
||||
app.directive('ellipsis', vEllipsis)
|
||||
app.use(router)
|
||||
.use(directives)
|
||||
.use(ElementPlus)
|
||||
.use(store)
|
||||
.component("SvgIcon", SvgIcon)
|
||||
.use(i18n)
|
||||
.mount('#app')
|
||||
|
||||
const vLoadimg = (el, binding) => {
|
||||
const src = binding.value
|
||||
if (el.src === src) return
|
||||
const img = new Image()
|
||||
img.src = src
|
||||
img.onload = () => {
|
||||
el.src = src
|
||||
}
|
||||
img.onerror = () => {
|
||||
console.log('图片加载失败:', src)
|
||||
}
|
||||
}
|
||||
// 注册
|
||||
app.directive('loadimg', vLoadimg)
|
||||
flexible();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user