一、复制链接
主要功能代码:document.execCommand('Copy');
copy() {
console.log('复制');
var inputTest = document.createElement('input');
inputTest.value = this.copyUrl;
// inputTest.value='11111111111';
document.body.appendChild(inputTest);
inputTest.select();
document.execCommand('Copy');
uni.showToast({
title: '复制成功',
icon: 'none'
});
},
二、文件预览
需求:需要在弹框中显示,所以要能嵌套到ui组件,并且就在本页面打开,不能跳转到新页面
所以用的iframe 标签
<u-popup :show="show_three" :round="10" :zIndex="zIndex_three" style='padding: 40rpx;' @close="close_three" >
<view class="popup_three" >
<view class="title">文件预览</view>
<iframe :src="copyUrl" width='100%' height='400rpx'></iframe></view>
</u-popup>
最开始用的web-view
但是无法嵌套到其他ui组件中,所以不符合要求
<template v-if='show_three'>
<view class="" style="padding: 20rpx;">
<web-view :src="copyUrl" ></web-view>
</view>
</template>
三、文件下载