小程序wx.request的url的url参数是怎么设置啊

https://123456/wx/scene/int:pk,最后面这个就是url参数,就是pk可以是一个动态数据吗。我现在只知道把int:pk改成数字然后传过去

:pk是参数?那应该用data来传

wx.request({
  url: 'example.php', //仅为示例,并非真实的接口地址
  data: {
    int:pk
  },
  header: {
    'content-type': 'application/json' // 默认值
  },
  success (res) {
    console.log(res.data)
  }
})

RequestTask | 微信开放文档 微信开发者平台文档 https://developers.weixin.qq.com/miniprogram/dev/api/network/request/wx.request.html

如果是get请求的话可以把数据拼在url里面
https://123456/wx/scene?int=pk 就可以了。

pk是数字动态的,可以在data中定义pk data{ pk:0 }
之后在要改变pk的地方 this.setData({pk:你要赋的值}) 就是动态的了

在请求方法中使用 this.data.pk 就可以了
var pkr = this.data.pk;
请求: 'https://123456/wx/scene?int='+pkr