jdost_26
jdost_26

Reputation: 415

Duplicate key with params value

In a vue app, I want to use a variable defined from a param, passed through the URL, in the template section. But when I try to use it, I get an undefined error when used in the template (though it is used in the script section and shows as defined).

I thought returning the variable would let me use it in the template section, but I get a duplicate key warning.

<template> 
   <div>
      <router-link
         :to="{ path: `/${m}`}" //this shows as undefined
      >Link</router-link>
   </div>
</template>
<script>
export default {
   name: "template",
   props: ["m"],
   setup() {
      const route = useRoute();
      const m = ref(route.params.m);
     
      console.log(m.value) //this works
         
      return {
         m //This shows as a duplicate key
      };
   },
};
</script>

Upvotes: 0

Views: 296

Answers (1)

Henock
Henock

Reputation: 108

Change variable name m in setup().

Upvotes: 2

Related Questions