|
|
@@ -148,6 +148,17 @@ export default {
|
|
|
}
|
|
|
},
|
|
|
watch: {
|
|
|
+ // 1. 监听路由参数中的 ID 变化 (核心修复)
|
|
|
+ '$route.params.id': {
|
|
|
+ handler(newId) {
|
|
|
+ if (newId) {
|
|
|
+ this.userId = newId;
|
|
|
+ this.resetPageState(); // 切换用户时,重置页码和列表
|
|
|
+ this.initUserContext(); // 重新加载用户资料和关系
|
|
|
+ }
|
|
|
+ },
|
|
|
+ immediate: true // 确保组件创建时也能触发
|
|
|
+ },
|
|
|
'$route.query': {
|
|
|
handler() {
|
|
|
this.loadDataFromRoute();
|
|
|
@@ -160,6 +171,14 @@ export default {
|
|
|
this.initUserContext();
|
|
|
},
|
|
|
methods: {
|
|
|
+ // 新增:切换用户时重置状态,防止数据残留
|
|
|
+ resetPageState() {
|
|
|
+ this.dataList = [];
|
|
|
+ this.currentPage = 1;
|
|
|
+ this.activeName = 'video';
|
|
|
+ this.user = null;
|
|
|
+ this.userContentData = null;
|
|
|
+ },
|
|
|
initUserContext() {
|
|
|
Promise.all([
|
|
|
getUserInfo(this.userId),
|