js——网址动态拼接参数

案例

你可以使用字符串拼接的方式来动态拼接参数到网址上。在这种情况下,你可以使用加号运算符来连接字符串,并使用变量来表示参数的值。下面是一个示例代码:

let aaa = "http://www.baidu.com";
let xxx = 1;
let yyy = 2;

let url = aaa + "?xxx=" + xxx + "&yyy=" + yyy;
console.log(url);//http://www.baidu.com?xxx=1&yyy=2

猜你喜欢

转载自blog.csdn.net/xulihua_75/article/details/132489416