birdpaper-ui
Version:
一个通用的 vue3 UI组件库。A common vue3 UI component library.
44 lines (43 loc) • 1.09 kB
JavaScript
import { defineComponent, computed } from "vue";
import { IconLoader4Line } from "birdpaper-icon";
const _sfc_main = defineComponent({
name: "Link",
props: {
/** 链接地址 */
href: { type: String, default: "javascript:;" },
/** 链接状态 */
status: { type: String, default: "primary" },
/** 是否禁用 */
disabled: { type: Boolean, default: false },
/** 是否加载状态 */
loading: { type: Boolean, default: false },
/** 跳转链接方式 */
target: { type: String, default: "_self" }
},
components: { IconLoader4Line },
emits: {
click: (ev) => true
},
setup(props, { emit }) {
const name = "bp-link";
const clsName = computed(() => {
let cls = [name, `${name}-status-${props.status}`];
if (props.disabled || props.loading)
cls.push(`${name}-disabled`);
return cls;
});
const handleClick = (e) => {
if (props.disabled)
return;
emit("click", e);
};
return {
name,
clsName,
handleClick
};
}
});
export {
_sfc_main as default
};