{"id":564,"date":"2023-09-16T17:20:01","date_gmt":"2023-09-16T09:20:01","guid":{"rendered":""},"modified":"2023-09-17T00:41:33","modified_gmt":"2023-09-16T16:41:33","slug":"%e5%89%8d%e7%ab%af-%e6%95%b0%e7%bb%84%e8%bd%ac%e5%ad%97%e7%ac%a6%e4%b8%b2%ef%bc%8c%e5%ad%97%e7%ac%a6%e4%b8%b2%e8%bd%ac%e6%95%b0%e7%bb%84","status":"publish","type":"post","link":"https:\/\/mushiming.com\/564.html","title":{"rendered":"\u524d\u7aef \u6570\u7ec4\u8f6c\u5b57\u7b26\u4e32\uff0c\u5b57\u7b26\u4e32\u8f6c\u6570\u7ec4"},"content":{"rendered":"<\/p>\n

\u524d\u6bb5\u65f6\u95f4\u5199\u4e86\u4e00\u4e2a\u9879\u76ee\uff0c\u9700\u8981\u7528\u5230\u7ea7\u8054\u9009\u62e9\u5668\uff0c\u5c31\u662f element \u7684\u7ea7\u8054\u9009\u62e9\u5668\u3002\u5728\u4fdd\u5b58\u6570\u636e\u7684\u65f6\u5019\uff0c\u524d\u7aef\u8fd9\u8fb9\u4fdd\u5b58\u7684\u662f\u6570\u636e\u5982\u679c\u4e0d\u662f\u4e00\u7ea7\u6570\u636e\uff0c\u5c31\u4f1a\u62ff\u5230\u4ed6\u7236\u7ea7\u7684id\u548c\u4ed6\u7684id\uff0c\u4f46\u662f\u540e\u7aef\u4e3a\u4e86\u4fdd\u8bc1\u6570\u636e\u91cf\u4e0d\u90a3\u4e48\u5927\uff0c\u4e0d\u60f3\u8981\u8fd9\u4e2a\u6570\u636e\u7236\u7ea7\u7684id\uff0c\u53ea\u60f3\u8981\u5176\u672c\u8eab\u7684id\u3002\u5e76\u4e14\u6211\u8fd9\u8fb9\u672c\u8eab\u4f20\u7684\u6570\u636e\u662f\u6570\u7ec4\uff0c\u800c\u540e\u7aef\u9700\u8981\u5b57\u7b26\u4e32\u6570\u636e\uff0c\u5c31\u6709\u4e86\u6211\u9700\u8981\u8f6c\u6765\u8f6c\u53bb\u7684\u64cd\u4f5c\u3002<\/p>\n

\u8fd9\u662f\u6211\u4fdd\u5b58\u7ea7\u8054\u9009\u62e9\u5668\u6570\u636e\u83b7\u53d6\u7684\u6570\u636e<\/h3>\n
[\n   ['02'],\n   ['05', '0501', '050101'],\n   ['01', '0101', '010105'],\n   ['01', '0104'],\n   ['04']\n ]<\/code><\/pre>\n

\u8fd9\u4e2a\u662f\u540e\u7aef\u60f3\u8981\u7684\u6570\u636e\u6837\u5b50<\/h3>\n
['02', '050101', '010105', '0104', '04']<\/code><\/pre>\n

\u5230\u8fd9\u91cc\u8fd8\u4e0d\u662f\u6700\u72d7\u7684\uff0c\u4e3a\u4e86\u8ba9\u7ea7\u8054\u9009\u62e9\u5668\u628a\u5df2\u9009\u62e9\u7684\u6570\u636e\u5c55\u793a\u51fa\u6765\uff0c\u6211\u5c55\u793a\u7684\u6570\u636e\uff0c\u6570\u636e\u9700\u8981\u7684\u683c\u5f0f\u662f\u8fd9\u6837\u7684<\/h3>\n
[\"02\", \"05,0501,050101\", \"01,0101,010105\", \"01,0104\", \"04\"]<\/code><\/pre>\n

\u4e5f\u5c31\u662f\u8bf4\u6211\u9700\u8981\u505a\u7684\u5c31\u662f\uff0c\u5728\u4fdd\u5b58\u7684\u65f6\u5019\u4ece\u83b7\u53d6\u7684\u6570\u636e\u6539\u6210\u540e\u7aef\u9700\u8981\u7684\u6570\u636e\uff0c\u7136\u540e\u5728\u6211\u9700\u8981\u5c55\u793a\u7684\u65f6\u5019\uff0c\u628a\u6570\u636e\u4ece\u540e\u7aef\u83b7\u53d6\u6765\u7684\u6570\u636e\u6539\u6210\u9700\u8981\u5c55\u793a\u7684\u6a21\u6837\uff0c\u7136\u540e\u628a\u6570\u636e\u518d\u8f6c\u5316\u6210\u6700\u5f00\u59cb\u5176\u4fdd\u5b58\u7684\u6837\u5b50\uff0c\u65b9\u4fbf\u8f6c\u6210\u540e\u7aef\u9700\u8981\u7684\u6570\u636e\u6837\u5b50\u3002\u6574\u4e2a\u8fc7\u7a0b\u4e2d\u8fd8\u8981\u8003\u8651\u6570\u636e\u4e3a\u7a7a\u7684\u60c5\u51b5\uff0c\u8fd8\u8981\u4fdd\u8bc1\u8f6c\u5316\u5b8c\u7684\u6570\u636e\u4e0d\u8981\u5728\u7b2c\u4e8c\u6b21\u8fdb\u884c\u4fdd\u5b58\u7684\u65f6\u5019\uff0c\u518d\u6b21\u8f6c\u5316\uff0c\u53d8\u6210\u8c01\u4e5f\u4e0d\u8ba4\u8bc6\u7684\u6570\u636e\u3002<\/p>\n

OK\uff0c\u63a5\u4e0b\u6765\u4e0a\u4ee3\u7801\u3002<\/p>\n

\u9996\u5148\u8981\u505a\u7684\u662f\u628a\u4fdd\u5b58\u7684\u6570\u636e\u8f6c\u5316\u6210\u540e\u7aef\u9700\u8981\u7684\u6570\u636e\uff0c\u5728\u8fd9\u91cc\u662f\u5728vue\u91cc\u5199\u4e86\u4e00\u4e2a\u65b9\u6cd5\uff0c\u5728\u4fdd\u5b58\u7684\u65f6\u5019\uff0c\u5bf9\u6570\u636e\u8fdb\u884c\u8f6c\u5316\u3002<\/h3>\n
majorData(data) {\n        \/\/ console.log(data)\n        if (data !== undefined) {\n            \/\/ console.log(this.ruleForm.isMappingMajor)\n            let sumData = [];\n            data.map((index) => {\n                if (index.length >= 6) {\n                    index = index.split(',')\n                }\n                \/\/ console.log(index)\n                if (index.length === 2 && index.constructor === Array) {\n                    index = index.slice(-1)\n                }\n                if (index.length === 3 && index.constructor === Array) {\n                    index = index.slice(-1)\n                }\n                sumData = sumData.concat(index)\n                return sumData\n            })\n            \/\/ console.log(newArr(sumData))\n            return newArr(sumData)\n        } else {\n            data = []\n            \/\/ console.log(data)\n            return data\n        }\n\n        function newArr(arr) {\n            return ([...new Set(arr)])\n        }\n    }<\/code><\/pre>\n

\u7136\u540e\u8981\u505a\u7684\u662f\u628a\u4ece\u540e\u7aef\u83b7\u53d6\u7684\u6570\u636e\uff0c\u8f6c\u5316\u6210\u524d\u7aef\u53ef\u4ee5\u5c55\u793a\u7684\u6570\u636e\uff0c\u8fd9\u91cc\u4e5f\u662f\u4e00\u4e2a\u65b9\u6cd5\uff0c\u628a\u540e\u7aef\u83b7\u53d6\u6765\u7684\u6570\u636e\u8fdb\u884c\u8f6c\u5316<\/h3>\n
useMajors(data) {\n      if (data !== null) {\n        var goodMajors = data.map(item => {\n          if (item.length === 4) {\n            item = item.substr(0, 2) + ',' + item\n          }\n          if (item.length === 6) {\n            item = item.substr(0, 2) + ',' + item.substr(0, 4) + ',' + item\n          }\n          return item\n        })\n        return goodMajors\n      }\n    }<\/code><\/pre>\n

\u597d\u4e86\uff0c\u6839\u636e\u4ee5\u4e0a\u7684\u4ee3\u7801\uff0c\u6211\u7684\u6570\u636e\u5c31\u53ef\u4ee5\u81ea\u5982\u8f6c\u5316\u4e86\uff0c\u63a5\u4e0b\u6765\u9644\u4e0a\uff0c\u6211\u5f53\u521d\u4e3a\u4e86\u5199\u65b9\u6cd5\u5199\u7684HTML\u6587\u4ef6\uff0c\u8fd9\u4e2a\u53ef\u80fd\u5e2e\u52a9\u4f1a\u66f4\u5927\u4e00\u4e9b<\/h3>\n
<!DOCTYPE html>\n<html lang=\"en\">\n\n<head>\n    <meta charset=\"UTF-8\">\n    <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">\n    <meta http-equiv=\"X-UA-Compatible\" content=\"ie=edge\">\n    <title>\u6570\u7ec4\u5206\u9694<\/title>\n<\/head>\n\n<body>\n\n<\/body>\n<script>\n    var arr1 = [\n        ['02'],\n        ['05', '0501', '050101'],\n        ['01', '0101', '010105'],\n        ['01', '0104'],\n        ['04']\n    ]\n    var arr2 = ['02', '050101', '010105', '0104', '04']\n    var sumData = [];\n    arr1.map((index) => {\n        console.log(index)\n        console.log(index.constructor == Array)\n        if (index.length === 2 && index.constructor === Array) {\n            index = index.slice(-1)\n        }\n        if (index.length === 3 && index.constructor === Array) {\n            index = index.slice(-1)\n        }\n        sumData = sumData.concat(index)\n        return sumData\n    })\n\n    function newArr(arr) {\n        \/\/ .new Set\u65b9\u6cd5\uff0c\u8fd4\u56de\u662f\u4e00\u4e2a\u7c7b\u6570\u7ec4\uff0c\u9700\u8981\u7ed3\u5408 ...\u8fd0\u7b97\u7b26\uff0c\u8f6c\u6210\u771f\u5b9e\u6570\u7ec4\n        return ([...new Set(arr)])\n    }\n    console.log(newArr(sumData))\n\n    var newData = newArr(sumData)\n\n    var good = newData.map((index) => {\n        if (index.length === 4) {\n            index = index.substr(0, 2) + ',' + index\n        }\n        if (index.length === 6) {\n            index = index.substr(0, 2) + ',' + index.substr(0, 4) + ',' + index\n        }\n        console.log(index)\n        return index\n    })\n    console.log(good)\n\n    var a = [\"02\", \"05,0501,050101\", \"01,0101,010105\", \"01,0104\", \"04\"]\n    var b = a.map((index) => {\n        if (index.length >= 6) {\n            index = index.split(',')\n        }\n        return index\n    })\n    console.log(b)\n<\/script>\n\n<\/html><\/code><\/pre>\n

\u4e0a\u9762\u7684\u65b9\u6cd5\u548c\u4e0b\u9762\u7684HTML\u4ee3\u7801\u76f8\u5bf9\u7167\u7740\u770b\uff0c\u4f1a\u66f4\u6e05\u6670\u54e6\uff01\uff01\uff01<\/p><\/p>\n","protected":false},"excerpt":{"rendered":"\u524d\u7aef \u6570\u7ec4\u8f6c\u5b57\u7b26\u4e32\uff0c\u5b57\u7b26\u4e32\u8f6c\u6570\u7ec4\u524d\u6bb5\u65f6\u95f4\u5199\u4e86\u4e00\u4e2a\u9879\u76ee\uff0c\u9700\u8981\u7528\u5230\u7ea7\u8054\u9009\u62e9\u5668\uff0c\u5c31\u662felement\u7684\u7ea7\u8054\u9009\u62e9\u5668\u3002\u5728\u4fdd\u5b58\u6570\u636e\u7684\u65f6\u5019\uff0c...","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[82],"tags":[],"_links":{"self":[{"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/posts\/564"}],"collection":[{"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/comments?post=564"}],"version-history":[{"count":0,"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/posts\/564\/revisions"}],"wp:attachment":[{"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/media?parent=564"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/categories?post=564"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/tags?post=564"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}