| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122 |
- <template>
- <div class="share">
- <div class="main">
- <div class="top">
- <h2>分享展览</h2>
- <i class="el-icon-close" @click="$emit('close')"></i>
- </div>
- <div class="myInput">
- https://lanhuapp.com/web/#/item/project/product?tid=de3e5e3
- </div>
- <div class="btn">
- <el-button type="primary" style="width:165px;height:40px" @click="copy">复制链接</el-button>
- </div>
- </div>
- </div>
- </template>
- <script>
- export default {
- name: "share",
- components: {},
- data() {
- //这里存放数据
- return {};
- },
- //监听属性 类似于data概念
- computed: {},
- //监控data中的数据变化
- watch: {},
- //方法集合
- methods: {
- copy(){
- // 存储传递过来的数据
- let OrderNumber = "9999999999";
- // 创建一个input 元素
- // createElement() 方法通过指定名称创建一个元素
- let newInput = document.createElement("input");
- // 讲存储的数据赋值给input的value值
- newInput.value = OrderNumber;
- // appendChild() 方法向节点添加最后一个子节点。
- document.body.appendChild(newInput);
- // 选中input元素中的文本
- // select() 方法用于选择该元素中的文本。
- newInput.select();
- // 执行浏览器复制命令
- // execCommand方法是执行一个对当前文档,当前选择或者给出范围的命令
- document.execCommand("Copy");
- // 清空输入框
- newInput.remove();
- // 下面是element的弹窗 不需要的自行删除就好
- this.$message({
- message: "复制成功",
- type: "success",
- });
- }
- },
- //生命周期 - 创建完成(可以访问当前this实例)
- created() {},
- //生命周期 - 挂载完成(可以访问DOM元素)
- mounted() {},
- beforeCreate() {}, //生命周期 - 创建之前
- beforeMount() {}, //生命周期 - 挂载之前
- beforeUpdate() {}, //生命周期 - 更新之前
- updated() {}, //生命周期 - 更新之后
- beforeDestroy() {}, //生命周期 - 销毁之前
- destroyed() {}, //生命周期 - 销毁完成
- activated() {}, //如果页面有keep-alive缓存功能,这个函数会触发
- };
- </script>
- <style lang='less' scoped>
- .share {
- position: fixed;
- top: 0;
- left: 0;
- z-index: 9999;
- width: 100vw;
- height: 100vh;
- .main {
- padding: 20px;
- border-radius: 3px;
- position: absolute;
- top: 50%;
- left: 50%;
- transform: translate(-50%, -50%);
- z-index: 9999;
- width: 500px;
- height: 220px;
- background: url("../../../assets/img/bg.png") no-repeat left bottom #b7cdd9;
- .top {
- margin-bottom: 20px;
- display: flex;
- justify-content: space-between;
- align-items: center;
- color: #165491;
- font-weight: 700;
- font-size: 22px;
- & > i {
- cursor: pointer;
- font-size: 30px;
- }
- }
- .myInput {
- overflow: hidden;
- text-overflow: ellipsis;
- white-space: nowrap;
- padding: 0 10px;
- width: 100%;
- height: 60px;
- line-height: 60px;
- background-color: #fff;
- border-radius: 5px;
- }
- .btn{
- margin-top: 20px;
- width: 100%;
- display: flex;
- justify-content: center;
- height: 40px;
- }
- }
- }
- </style>
|