-
Notifications
You must be signed in to change notification settings - Fork 137
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
jry
committed
Apr 7, 2024
1 parent
270651a
commit 3ee730e
Showing
9 changed files
with
138 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<template> | ||
<view class="u-page"> | ||
<view class="u-page__item"> | ||
<text class="u-page__item__title" style="margin-top: 0;">点击文字复制</text> | ||
<view class="u-page__item__content"> | ||
<up-copy content="uview-plus is great !"> | ||
<text>点击复制</text> | ||
</up-copy> | ||
</view> | ||
</view> | ||
<view class="u-page__item"> | ||
<text class="u-page__item__title" style="margin-top: 0;">点击按钮复制</text> | ||
<view class="u-page__item__content"> | ||
<up-copy content="uview-plus is great !"> | ||
<up-button type="primary">点击复制</up-button> | ||
</up-copy> | ||
</view> | ||
</view> | ||
</view> | ||
</template> | ||
|
||
<script setup> | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
<template> | ||
<view @click="handleClick"> | ||
<slot>复制</slot> | ||
</view> | ||
</template> | ||
<script> | ||
export default { | ||
name: "xy-copy", | ||
props: { | ||
content: { | ||
type: String, | ||
default: '' | ||
}, | ||
alertStyle: { | ||
type: String, | ||
default: 'toast' | ||
}, | ||
notice: { | ||
type: String, | ||
default: '复制成功' | ||
} | ||
}, | ||
emits: ['success'], | ||
methods: { | ||
handleClick() { | ||
let content = this.content; | ||
if (!content) { | ||
uni.showToast({ | ||
title: '暂无', | ||
icon: 'none', | ||
duration: 2000, | ||
}); | ||
return false; | ||
} | ||
content = typeof content === 'string' ? content : content.toString() // 复制内容,必须字符串,数字需要转换为字符串 | ||
/** | ||
* 小程序端 和 app端的复制逻辑 | ||
*/ | ||
let that = this; | ||
uni.setClipboardData({ | ||
data: content, | ||
success: function() { | ||
if (that.alertStyle == 'modal') { | ||
uni.showModal({ | ||
title: '提示', | ||
content: that.notice | ||
}); | ||
} else { | ||
uni.showToast({ | ||
title: that.notice, | ||
icon: 'none' | ||
}); | ||
} | ||
that.$emit('success'); | ||
}, | ||
fail:function(){ | ||
uni.showToast({ | ||
title: '复制失败', | ||
icon: 'none', | ||
duration:3000, | ||
}); | ||
} | ||
}); | ||
} | ||
} | ||
} | ||
</script> | ||
|
||
<style lang="scss" scoped> | ||
</style> |