使用this.$router.push()方法页面跳转后不加载列表刷新

news/2024/7/9 23:39:57 标签: vue, 路由

使用this.$router.push()方法页面跳转后不加载列表刷新

注意:created()方法是无效的

方法:在需要刷新的页面添加以下内容

1. 代码实现:

 watch:{
   $route(){
     //跳转到该页面后需要进行的操作
   }
 },

2. 示例:

(1)子组件

onSubmit () {
    	this.$http[!this.form.id ? 'post' : 'put']('/cd/question', {...this.form}).then(({ data: res }) => {
          if (res && res.code === 0) {
            this.$message({
              message: '操作成功',
              type: 'success',
              duration: 500,
              onClose: () => {
              }
            })
            this.$router.push({ name: 'user-question' })
          } else {
            this.$message.error(res.msg)
          }
        })
      },

(2)父组件(user-question)
在子组件用this.$emit('refreshDataList', true);无效
所以在父组件使用监听路由的方法

 watch: {
    $route () {
      this.getDataList();
    }
  },

this.getDataList():是列表查询的方法


http://www.niftyadmin.cn/n/1302079.html

相关文章

Element UI自带的小图标,替换成自己的

Element UI自带的小图标,替换成自己的 代码: .el-icon-date {background: url(你的图片路径) center center no-repeat;background-size: 20px; }.el-icon-date:before {content: "替";font-size: 16px;visibility: hidden; }注意这里除了cl…

springboot集成统一认证服务

springboot集成统一认证服务 配置文件配置属性 # 统一认证登录 # cas服务地址 cas.loginServerhttps://xxx.xxx.xxx/cas #cas服务端的登录地址 cas.validateServerhttps://xxx.xxx.xxx/cas #当前服务器的地址(客户端) cas.serverName当前服务地址配置类 (1&…

java excel 导出多个sheet

java excel 导出多个sheet 装载数据的实体类 package com.yfh.common.core.domain; import lombok.AllArgsConstructor; import lombok.Data; import lombok.NoArgsConstructor; import java.io.Serializable; import java.util.List; import java.util.Map;/*** author zdj* v…

java 路径截取--截取倒数第二个指定字符之前/后的字符串

java 路径截取–截取倒数第二个指定字符之前/后的字符串 截取倒数第二个"/"之前的字符串 String path"/home/henry/Desktop/1.txt";//获得""/home/henry",并且不需要前面的"/" String oopath.substring(0,path.lastIndexOf("…

springboot集成easypoi实现excel多sheet导入

springboot集成easypoi实现excel多sheet导入 pom依赖 <!--easypoi依赖&#xff0c;excel导入导出--> <dependency><groupId>cn.afterturn</groupId><artifactId>easypoi-spring-boot-starter</artifactId><version>4.3.0</versio…

springboot集成easypoi实现excel多sheet导入案例

springboot集成easypoi实现excel多sheet导入案例 pom依赖 <!--easypoi依赖&#xff0c;excel导入导出--> <dependency><groupId>cn.afterturn</groupId><artifactId>easypoi-spring-boot-starter</artifactId><version>4.3.0</ve…

springboot集成easypoi实现excel多sheet导出,并设置表头样式

springboot集成easypoi实现excel多sheet导出&#xff0c;并设置表头样式 导入依赖 <!--easypoi依赖&#xff0c;excel导入导出--> <dependency><groupId>cn.afterturn</groupId><artifactId>easypoi-spring-boot-starter</artifactId><…

mysql 限定时间段范围

mysql 限定时间段范围 startTime: 开始时间 endTime&#xff1a;结束时间 select * from table where ((start_time > startTime and start_time < endTime) OR(start_time startTime and end_time > endTime) OR(end_time > startTime and end_time < endTi…