Vue project, some of the code logic in the project is the same, the writing is also the same, how do I encapsulate it into a common method to complete different functions. Look at my detailed description.

1, vue project, where calling the local interface in the user center setting has a lot in common.
2, for example:
on configuring the shortcut key to send messages, our interface has to add local configuration and to update the local configuration . When I want to set the shortcut key to send messages, I need to judge that if this configuration exists locally, then use to update the local configuration interface. Different actions should also be done in a successful callback. There are also the configuration of friends online voice reminders and many other similar operations, at present, I write their own, but I think this writing is a bit of a repetitive meaning of moving bricks, how should I optimize my code.
3,

setSendMsgKey(action, val, keyName){
      console.log(action, "action"); // action
      let tempVal = val;
      if(val == "0") tempVal = "CTRL_ENTER";
      if(val == "1") tempVal = "ENTER";
      let setSendMsgKeyCB = resp => {
        console.log(resp, "");
        if(resp.code == 0){
          this.$store.commit("SET_USER_LOCALCONFIG", { key: "send_msg_key", value: tempVal });
          if(action == "addLocalSetting") this.$store.commit("SET_USER_LOCALCONFIG", { key: keyName, value: true });
        }
      }
      if(action == "addLocalSetting"){
        this.$Service.user.addLocalSetting(
          [{ key: "send_msg_key", value: tempVal }],
          setSendMsgKeyCB
        )
      } else {
        this.$Service.user.updateLocalSetting(
          [{ key: "send_msg_key", value: tempVal }],
          setSendMsgKeyCB
        )
      }
    },

it is recommended to create util.js to store custom public methods, and call import when needed.

or define the method within an object


Vue.prototype.$setSendMsgKey= function(action, val, keyName,setSendMsgKeyCB){
    ...
}

use

when you use it later.
this.$setSendMsgKey(.. , resp => {
    ...
})

is that what it means?

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-1e4494a-44aca.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-1e4494a-44aca.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?