vue.js: how to handle click and dblclick events on same element

后端 未结 7 2208
粉色の甜心
粉色の甜心 2021-02-01 16:01

I have a vue component with separate events for click/dblclik. Single click (de)selects row, dblclick opens edit form.

7条回答
  •  长发绾君心
    2021-02-01 16:26

    selectedFolder = ''; // string of currently selected item
    folderSelected = false; // preview selected item
    
    selectFolder(folder) {
        if (this.selectedFolder == folder) {
            // double click
          this.folderSelected = false;
          this.$store.dispatch('get_data_for_this_folder', folder);
        } else {
          // single click
          this.selectedFolder = folder;
          this.folderSelected = true;
        }
    },
    

提交回复
热议问题