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"));
     }
     );
    },
  • 相关阅读:
    python深浅copy探究
    构建squid代理服务器
    python列表和元组操作
    python字符串操作
    Apache虚拟主机
    Apache访问控制
    部署AWStats分析系统
    LAMP平台部署
    二分查找
    设计模式六大原则
  • 原文地址:https://www.cnblogs.com/zdz8207/p/vue-clipboard2-url-route-invitecode.html
Copyright © 2011-2022 走看看