js、vue截取url參數


url地址如:http://43.40.39.417/td?id=14

在開發中偶爾會出現要前端自己截取url中的id

  可以使用js的split方法來截取

  

self.$nextTick(function() {
    var url = window.location.href;
    let id = '';
    if (url.indexOf("?id=") != -1) {
        id = url.split('?id=')[1];10.42+15.83+10.21+14.78+2.34
        if (id.indexOf("#") != -1) {
            id = id.split('#')[0];
        }
        self.id = id;
    }
})

 

  


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM