Skip to content

Instantly share code, notes, and snippets.

@siumhossain
Created June 8, 2022 05:27
Show Gist options
  • Save siumhossain/01926f7c2b8b36b4ec1db69aac99dae0 to your computer and use it in GitHub Desktop.
Save siumhossain/01926f7c2b8b36b4ec1db69aac99dae0 to your computer and use it in GitHub Desktop.
create link from title

take title valye from product title and put - between space and push to new url

 methods:{
       product(value){
           console.log(value)
           const title = value.title
            const clearTitle = title.replaceAll(' ','-')
            console.log(clearTitle)
            this.$router.push({
                path:`/${clearTitle}/`,
            })
       },
     
       

receive this into new dynamic page and meke process

       try{
           const route = this.$router.history.current.path;
           this.routeName = route
           const title = route.split("-").join(" ");
           const finalTitle = title.replace(/\\|\//g, "");
       
       
       
           const res = await this.$axios.$get(`productByTitle/${finalTitle}/`);
           this.obj = res.data;
           this.title = this.obj.title
           this.image = this.obj.image
           this.description = res.data.description;
           console.log(res.status)

       }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment