Created
December 8, 2020 19:01
-
-
Save jaydenlin/75da85560f89a11c88a42de902d48586 to your computer and use it in GitHub Desktop.
getCheckedKeys.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const parseTagId = (key) => { | |
//取 tag_588 中的 tag id 數字 | |
return key.match(/\d+/g) === null ? null: key.match(/\d+/g)[0]; | |
} | |
const isTagKey = (key) => { | |
//判斷是不是 tag (資料夾會是undefined) 以及是否可以取 tag id | |
return typeof key !== "undefined" && parseTagId(key) !== null; | |
} | |
const getCheckedKeys = () => { | |
const dataKeys = this.$refs['tree'].getCheckedKeys(); | |
// | |
this.tag_ids = dataKeys.filter((key)=>{ | |
return isTagKey(key); // 篩選取 tag | |
}).map((key)=>{ | |
return parseTagId(key);// 爬出 tag id 回傳 | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment