vue通过h5跳转传值和获取

78 阅读1分钟

封装的js方法,通过$.Request("")获取值

   (function ($) {
    $.extend({
        //1、取值使用    $.Request("name")
        Request: function (name) {
            var sValue = location.search.match(new RegExp("[\?\&]" + name + "=([^\&]*)(\&?)", "i"));
            //decodeURIComponent解码
            return sValue ? decodeURIComponent(sValue[1]) : decodeURIComponent(sValue);
        }
    });
})(jQuery);

传值

   new Vue({
    el: "#root",
    data: {
       
    },
    methods: {
    
        submitBtn() {
            window.location.href= encodeURI("about.html?orderNo="+'你在哪里'+'&id='+5)
        }
    }
})

接收值

    new Vue({
        el: "#root",
        data: {
            name:""
        },
        mounted() {
            this.name = $.Request("surname")

        }
    })