From d8b41fff43a2cee6a8f714ffa807623b15803786 Mon Sep 17 00:00:00 2001 From: quanyawei <401863037@qq.com> Date: Fri, 20 Oct 2023 15:21:35 +0800 Subject: [PATCH] fix:立行立改Uniapp小程序新建项目 --- uni_modules/uview-ui/components/u-link/u-link.vue | 83 +++++++++++++++++++++++++++++++++++++++++ 1 files changed, 83 insertions(+), 0 deletions(-) diff --git a/uni_modules/uview-ui/components/u-link/u-link.vue b/uni_modules/uview-ui/components/u-link/u-link.vue new file mode 100644 index 0000000..c6802a5 --- /dev/null +++ b/uni_modules/uview-ui/components/u-link/u-link.vue @@ -0,0 +1,83 @@ +<template> + <text + class="u-link" + @tap.stop="openLink" + :style="[linkStyle, $u.addStyle(customStyle)]" + >{{text}}</text> +</template> + +<script> + import props from './props.js'; + + /** + * link ��������� + * @description ������������������������������������������������������������������������APP���������������plus���������������������������������������������������������������������������������������������������H5���������window.open��������������� + * @tutorial https://www.uviewui.com/components/link.html + * @property {String} color ������������ ��������� color['u-primary'] ��� + * @property {String ��� Number} fontSize ���������������������px ��������� 15 ��� + * @property {Boolean} underLine ��������������������� ��������� false ��� + * @property {String} href ���������������������������http(s) + * @property {String} mpTips ������������������������������������������������������������������������������������������������������������������������ + * @property {String} lineColor ���������������������������color������������ + * @property {String} text ������������������������������slot������������������������nvue��������������������� + * @property {Object} customStyle ��������������������������������� + * + * @example <u-link href="http://www.uviewui.com">���������������������������</u-link> + */ + export default { + name: "u-link", + mixins: [uni.$u.mpMixin, uni.$u.mixin,props], + computed: { + linkStyle() { + const style = { + color: this.color, + fontSize: uni.$u.addUnit(this.fontSize), + // line-height���������������������������2px + lineHeight: uni.$u.addUnit(uni.$u.getPx(this.fontSize) + 2), + textDecoration: this.underLine ? 'underline' : 'none' + } + // if (this.underLine) { + // style.borderBottomColor = this.lineColor || this.color + // style.borderBottomWidth = '1px' + // } + return style + } + }, + methods: { + openLink() { + // #ifdef APP-PLUS + plus.runtime.openURL(this.href) + // #endif + // #ifdef H5 + window.open(this.href) + // #endif + // #ifdef MP + uni.setClipboardData({ + data: this.href, + success: () => { + uni.hideToast(); + this.$nextTick(() => { + uni.$u.toast(this.mpTips); + }) + } + }); + // #endif + this.$emit('click') + } + } + } +</script> + +<style lang="scss" scoped> + @import "../../libs/css/components.scss"; + $u-link-line-height:1 !default; + + .u-link { + /* #ifndef APP-NVUE */ + line-height: $u-link-line-height; + /* #endif */ + @include flex; + flex-wrap: wrap; + flex: 1; + } +</style> -- Gitblit v1.8.0