字符串和三元表达式连接使用时,需要在三元表达式上加括号

   通过接口获取数据后,返回的参数想要添加在提示信息后面,需要添加括号
   
      if (res.code === '1') {
        // 上传成功
        this.$message.success(this.$t('dataManagement.successfulSubmis')+':'+ (res.data==null||''?'':res.data))
      this.$emit('updateTable') //导入数据成功后,调用父组件的方法更新列表
      this.visible = false
    } else {
      self.$message.error(this.$t('dataManagement.failureToSubmit')+':'+ (res.msg==null||''?'':res.msg))
    }  
    }).catch( err =>   {
      // 提交失败
      self.$message.error(this.$t('dataManagement.failureToSubmit') +':'+ ( res.msg==null||''?'':res.msg))
    })
  } else {
    this.$message.warning(this.$t('dataManagement.pleaseSelectTheFileFirst'))
  }

如果不添加括号的话
前面的字符串自动忽略。

猜你喜欢

转载自blog.csdn.net/weixin_34285318/article/details/88244159