Encapsulated the prompt box of Elementui and reported an error

this is an example given by the official of ele.me:

this.$alert("", "", {
     confirmButtonText: "",
          callback: action => {
            this.$message({
              type: "info",
              message: `action: ${ action }`
            });
          }
        });
      }

there is too much code, so I want to package one myself:

import { Message } from "element-ui"

export function alertOK(msg,title){
    this.$alert(msg, title, {
        confirmButtonText: "",
        callback: action => {
            this.$message({
                type: "info"
            });
        }
    });
}

export default {alertOK}

set to global, main.js:

import common from "@/common/global.js"
Vue.prototype.$common = common

call Times error:

submit:function(){
    this.$common.alertOK("","");
}

clipboard.png


export function alertOK(msg,title){
    this.$alert(msg, title, {
    ...
}

your this points to the wrong one. When executing this.$common.alertOK , the above this points to common .

Change

to

    this.$common.alertOK.call(this,"","")

this pointing problem.

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e454fd-43e7c.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e454fd-43e7c.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?