vue跳转带参数---【购物商城项目】(2020.3.13)

vue基础,路由跳转带参数,第一次记录

回忆提示:

:这里所有的后台数据都来自接口,接口地址:https://www.showdoc.cc/veblen?page_id=3372089088105270
商品一级分类跳转到各个分类的详情页面
一级分类HTML

<span v-bind:key="index" v-for="(one_type,index) in goods_type" class="goods_type" @click="turn_to_type(one_type)">
	<el-button round style="height: 30px; width: 100px; line-height: 5px;">{{one_type}}</el-button>
</span>

一级分类script

methods: {
			turn_to_type: function(e) {
				// console.log(e);
				this.$router.push('/list/' + e)
			}
		},

VUE路由

import list from "../views/list";
{
	path:'/list/:type',
	name:"List",
	component: list
},

分类详情页面script

<script>
    import axios from 'axios'
    import Goods_types from "../components/goods_types";
    import Turn_to_top from "../components/turn_to_top";
    export default {
        name: "list",
        components: {Turn_to_top, Goods_types},
        data(){
          return{
              goods_list:[]
          }
        },
        methods:{
            get_goods_list: function (e) {
				console.log(e);
                const self=this;
                axios.get('http://vebcoder.cn/api/goodList', {
                    params: e
                    //参数e就是所求
                }).then(
                    function (response) {
                        // console.log(response.data)
                        self.goods_list=response.data;
                        // this.$forceUpdate()
                    }
                )
            },
			to_details: function(e) {
				this.$router.push('/details/'+e)
			}
        },
        mounted() {
            // console.log(this.$route.params.type)

            this.get_goods_list({"type_one":this.$route.params.type})
        },
        watch:{
            $route:function () {
                this.get_goods_list({"type_one":this.$route.params.type})
            }
        }
    }
</script>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值