throw new Error() 真实的用法和throw error 的用法

1:  throw new Error() 用法与 throw error 用法:

       throw new Error();   创建错误, 创建一个错误里类型抛出。

 if (res && res.code) {
   this.$Modal.success({
     title: "提示",
     content: "保存成功"
   });
    this.$emit("closeDialog", {
      isShow: false,
      isRefresh: true
      });
    } else {
    throw new Error("保存失败,请稍后再试!");
 }

  自己手动创建一个错误。

throw  error:  这个是抛出错误。

猜你喜欢

转载自blog.csdn.net/weixin_45677987/article/details/114535341