"Nuxt.js: Pass ID using URL"-PHP Chinese Network Q&A
"Nuxt.js: Pass ID using URL"
P粉511985082
P粉511985082 2023-08-26 00:11:20
0
2
435

I want to get the user ID, so I have a dropdown button =

    {{item.title}}    

And this data:

 

My intention is to send the user ID. This way, I can actually get

via route.params.id
url: ''/user/function/structUser/${route.params.id}`' 

Not working, what did I do wrong?

P粉511985082
P粉511985082

reply all (2)
P粉060112396
  1. The template string only uses backticks, but your string uses both single quotes and backticks.

  2. The
  3. replacement value (route.params.id) refers to aroutevariable that appears to be undefined in your example. I think you want to accessthis.$route, so the actual replacement should bethis.$route.params.id

itemsThe array should look like this:

export default { data() { return { items: [ { title: 'List User', url: `/user/function/listUser/${this.$route.params.id}` }, { title: 'structure User', url: `/user/function/structUser/${this.$route.params.id}` } ] } } }

Demo

    P粉293341969

    This is an example

    `/user/function/structUser/${this.$route.params.id}`

    Also, maybe try using it inside acomputedas it may not be a computed property.

      Latest Downloads
      More>
      Web Effects
      Website Source Code
      Website Materials
      Front End Template
      About us Disclaimer Sitemap
      php.cn:Public welfare online PHP training,Help PHP learners grow quickly!