在网关服务中配置:
- id: product_route
uri: lb://gulimall-product
predicates:
- Path=/api/product/**
filters:
- RewritePath=/api/(?<segment>.*),/$\{segment}
注意:此路由要放在我们在上篇文章配置的定向到renren-fast的路由之上,否则不会生效
<template>
<el-tree
:data="menus"
:props="defaultProps"
@node-click="hanldeNodeClick"
></el-tree>
</template>
<script>
export default {
data() {
return {
menus: [],
defaultProps: {
children: "children",
label: "name",
}
};
},
created() {
this.getMenus();
},
methods: {
getMenus() {
this.$http({
url: this.$http.adornUrl("/product/category/list/tree"),
method: "get",
}).then(({ data }) => {
console.log("成功获取后台数据", data.data);
this.menus = data.data;
});
},
},
};
</script>