{"id":261,"date":"2020-09-14T00:16:43","date_gmt":"2020-09-13T16:16:43","guid":{"rendered":"http:\/\/moyisuiying.com\/?p=261"},"modified":"2020-12-10T14:23:35","modified_gmt":"2020-12-10T06:23:35","slug":"datatable%e4%b8%ad%e6%8a%a5%e9%94%99-table-xxx-is-not-a-function%e7%9a%84%e8%a7%a3%e5%86%b3%e6%96%b9%e6%b3%95","status":"publish","type":"post","link":"http:\/\/moyisuiying.com\/index.php\/web\/datatable\/261.html","title":{"rendered":"datatable\u4e2d\u62a5\u9519 table.XXX  is not a function\u7684\u89e3\u51b3\u65b9\u6cd5"},"content":{"rendered":"\n<p>\u5728datatable\u4e2d\u53ef\u4ee5\u901a\u8fc7\u4e09\u79cd\u4e0d\u540c\u7684\u65b9\u5f0f\u4e3a\u4e00\u4e2a\u6216\u591a\u4e2a\u8868\u83b7\u53d6\u4e00\u4e2a\u65b0\u7684Datatables API\u5b9e\u4f8b\uff1a<br>\uff081\uff09$ ( selector ).DataTable();<br>\uff082\uff09$ ( selector ).dataTable().api();<br>\uff083\uff09new $ .fn.dataTable.Api( selector );<br>\u6bcf\u79cd\u65b9\u5f0f\u7684\u7ed3\u679c\u90fd\u662fDatatables API\u5bf9\u8c61\u7684\u4e00\u4e2a\u5b9e\u4f8b\uff0c\u8be5\u5b9e\u4f8b\u5177\u6709\u9009\u62e9\u5668\u5728\u5176\u4e0a\u4e0b\u6587\u4e2d\u627e\u5230\u7684\u8868\u3002\u8bf7\u52a1\u5fc5\u6ce8\u610f$ ( selector ).DataTable();\u548c$ ( selector ).dataTable();\u4e4b\u95f4\u7684\u533a\u522b\u3002\u524d\u8005\u8fd4\u56deDatatables API\u5b9e\u4f8b\uff0c\u800c\u540e\u8005\u8fd4\u56de jQueryType \u5bf9\u8c61\u3002\u4f7f\u7528api()\u65b9\u6cd5\u6dfb\u52a0\u5230jQuery\u5bf9\u8c61\uff0c\u4f60\u4e5f\u53ef\u4ee5\u8f7b\u677e\u8bbf\u95eeAPI\uff0c\u4f46\u662fjQuery\u5bf9\u8c61\u5bf9\u4e8e\u64cd\u4f5c\u8868\u8282\u70b9\u53ef\u80fd\u5f88\u6709\u7528\uff0c\u5c31\u50cf\u5904\u7406\u5176\u4ed6jQuery\u5b9e\u4f8b\u4e00\u6837\uff08\u6bd4\u5982\u4f7f\u7528addClass()\u7b49\u7b49\uff09\u3002\u56e0\u6b64\u5f53\u51fa\u73b0\u201c table.XXX is not a function\u201d\u65f6\uff0c\u9996\u5148\u770b\u4f60\u7684 var table =$ ( selector ).DataTable()\u8fd8\u662fvar table =$ ( selector ).dataTable().\u5982\u679c\u662f\u524d\u8005\uff0c\u8bf4\u660etable.xxxx()\u7684xxx\u4e0d\u662f\u4e00\u4e2a\u51fd\u6570\uff1b\u5982\u679c\u662f\u540e\u8005\uff0c\u5219\u9700\u8981\u5c06table.xxx\u6539\u4e3a table.api().xxx()\u7684\u65b9\u5f0f\u8fd9\u6837\u624d\u80fd\u591f\u6b63\u5e38\u4f7f\u7528datatable\u7684api.\u5f53\u7136\uff0c\u4f60\u4e5f\u53ef\u4ee5\u76f4\u63a5\u5c06var table =$ ( selector ).dataTable()\u6539\u4e3avar table =$ ( selector ).DataTable()\u5373\u53ef\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>datatable\u4e2d\u62a5\u9519 table.XXX  is not a function\u7684\u89e3\u51b3\u65b9\u6cd5<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[52],"tags":[53],"_links":{"self":[{"href":"http:\/\/moyisuiying.com\/index.php\/wp-json\/wp\/v2\/posts\/261"}],"collection":[{"href":"http:\/\/moyisuiying.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/moyisuiying.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/moyisuiying.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/moyisuiying.com\/index.php\/wp-json\/wp\/v2\/comments?post=261"}],"version-history":[{"count":1,"href":"http:\/\/moyisuiying.com\/index.php\/wp-json\/wp\/v2\/posts\/261\/revisions"}],"predecessor-version":[{"id":262,"href":"http:\/\/moyisuiying.com\/index.php\/wp-json\/wp\/v2\/posts\/261\/revisions\/262"}],"wp:attachment":[{"href":"http:\/\/moyisuiying.com\/index.php\/wp-json\/wp\/v2\/media?parent=261"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/moyisuiying.com\/index.php\/wp-json\/wp\/v2\/categories?post=261"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/moyisuiying.com\/index.php\/wp-json\/wp\/v2\/tags?post=261"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}