zoukankan      html  css  js  c++  java
  • vue获得当前页面URL动态拼接URL复制邀请链接方法

    vue获得当前页面URL动态拼接URL复制邀请链接方法

    当前页面完整url可以用 location.href
    路由路径可以用 this.$route.path
    路由路径参数 this.$route.params
    实例:动态邀请链接,获得当前页面URL去掉path,替换成注册的加上邀请码:
    this.invitelink = location.href.replace(this.$route.path,'') + "/register?invitecode=" + this.invitecode;

    a标签的写法
    <!-格式如下,href前要加上冒号--->
    <a :href="'index.shtml?other='+object.name">这是一个动态链接</a>
    <a :href="'${request.contextPath}/admin/getId/'+r.id">编辑</a>

    ===============
    复制邀请链接方法:
    main.js里添加:
    import VueClipboard from 'vue-clipboard2'
    Vue.use(VueClipboard)
    -----------
    页面使用方法:

    copyInvitelink(){
     var this_ = this;
     this.$copyText(this.invitelink).then(
     function(e) {
        Toast.info(this_.$t("my.copedLink"));
     },
     function(e) {
        console.log(this_.$t("my.copeErr"));
     }
     );
    },
  • 相关阅读:
    原生小程序音频播放
    Vue定义全局过滤器filter
    系统扩展性之引入外部包
    oracle update join
    OAuth2
    oracle pl/sql
    MySQL同步工具otter的使用介绍(一)
    python批量安装apk
    mac brew安装redis
    antd 修改Modal的底部按钮颜色
  • 原文地址:https://www.cnblogs.com/zdz8207/p/vue-clipboard2-url-route-invitecode.html
Copyright © 2011-2022 走看看