mirror of
https://github.com/jumpserver/lina.git
synced 2025-04-27 03:00:47 +00:00
24 lines
603 B
JavaScript
24 lines
603 B
JavaScript
import Vue from 'vue'
|
|
|
|
Vue.directive('async', {
|
|
async bind(el, binding) {
|
|
const { value: asyncFn, arg } = binding
|
|
if (typeof asyncFn === 'function') {
|
|
const result = await asyncFn(arg)
|
|
el.innerText = result
|
|
}
|
|
},
|
|
async update(el, binding) {
|
|
const { value: asyncFn, arg } = binding
|
|
if (typeof asyncFn === 'function') {
|
|
const result = await asyncFn(arg)
|
|
el.innerText = result
|
|
} else if (typeof asyncFn === 'object' && asyncFn.then) {
|
|
const result = await asyncFn
|
|
el.innerText = result
|
|
} else {
|
|
el.innerText = asyncFn
|
|
}
|
|
}
|
|
})
|