From d1448cb0ef10f358bb7bddb4e1ec268515e0b787 Mon Sep 17 00:00:00 2001 From: gaoluyang <2820782392@qq.com> Date: 星期二, 15 七月 2025 11:46:57 +0800 Subject: [PATCH] 项目初始化 --- 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鐜鎵撳紑鍐呯疆娴忚鍣紝鍦ㄥ皬绋嬪簭涓妸閾炬帴澶嶅埗鍒扮矘璐存澘锛屽悓鏃舵彁绀轰俊鎭紝鍦℉5涓�氳繃window.open鎵撳紑閾炬帴銆� + * @tutorial https://www.uviewui.com/components/link.html + * @property {String} color 鏂囧瓧棰滆壊 锛堥粯璁� color['u-primary'] 锛� + * @property {String 锝� Number} fontSize 瀛椾綋澶у皬锛屽崟浣峱x 锛堥粯璁� 15 锛� + * @property {Boolean} underLine 鏄惁鏄剧ず涓嬪垝绾� 锛堥粯璁� false 锛� + * @property {String} href 璺宠浆鐨勯摼鎺ワ紝瑕佸甫涓奾ttp(s) + * @property {String} mpTips 鍚勪釜灏忕▼搴忓钩鍙版妸閾炬帴澶嶅埗鍒扮矘璐存澘鍚庣殑鎻愮ず璇紙榛樿鈥滈摼鎺ュ凡澶嶅埗锛岃鍦ㄦ祻瑙堝櫒鎵撳紑鈥濓級 + * @property {String} lineColor 涓嬪垝绾块鑹诧紝榛樿鍚宑olor鍙傛暟棰滆壊 + * @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.9.3