{"id":2425,"date":"2020-06-25T23:30:30","date_gmt":"2020-06-25T15:30:30","guid":{"rendered":"http:\/\/www.ponybai.com\/?p=2425"},"modified":"2020-06-25T23:30:30","modified_gmt":"2020-06-25T15:30:30","slug":"salesforce%e5%bc%80%e5%8f%91%e4%ba%ba%e5%91%98%e7%9a%84javascript%e6%8a%80%e8%83%bd-%e7%bc%96%e5%86%99%e5%bc%82%e6%ad%a5javascript","status":"publish","type":"post","link":"http:\/\/www.ponybai.com\/?p=2425","title":{"rendered":"Salesforce\u5f00\u53d1\u4eba\u5458\u7684JavaScript\u6280\u80fd-\u7f16\u5199\u5f02\u6b65JavaScript"},"content":{"rendered":"\n\t\t\t\t\n<h2 class=\"wp-block-heading\">\u5b66\u4e60\u76ee\u6807<\/h2>\n\n\n\n<p>\u5b8c\u6210\u672c\u5355\u5143\u540e\uff0c\u60a8\u5c06\u80fd\u591f\uff1a<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>\u8bc6\u522bJavaScript\u4e2d\u91cd\u8981\u7684\u5f02\u6b65\u529f\u80fd\u3002<\/li><li>\u4f7f\u7528setTimeout\u5f02\u6b65\u8c03\u7528\u51fd\u6570\u3002<\/li><li>\u7f16\u5199\u548c\u8c03\u7528\u56de\u8c03\u51fd\u6570\u3002<\/li><li>\u7f16\u5199\u548c\u8c03\u7528\u57fa\u4e8epromise\u7684\u51fd\u6570\u3002<\/li><li>\u63cf\u8ff0Aura\u7ec4\u4ef6\u4e2d\u7684\u5f02\u6b65\u529f\u80fd\u3002<\/li><\/ul>\n\n\n\n<p>\u56de\u60f3\u8d77\u6211\u4eec\u6700\u521d\u5f15\u5165JavaScript\u5f15\u64ce\u65f6\u7684\u65b9\u5f0f\u3002\u5f15\u64ce\u6709\u4e00\u4e2a\u5355\u7ebf\u7a0b\uff0c\u5b83\u53ef\u4ee5\u6b63\u5e38\u5de5\u4f5c\uff0c\u5b8c\u6210\u5de5\u4f5c\uff0c\u7136\u540e\u586b\u5145\u65b0\u7684\u5de5\u4f5c\u4ee5\u91cd\u65b0\u5f00\u59cb\u3002<\/p>\n\n\n\n<p>\u5f53\u7136\uff0c\u81f3\u5173\u91cd\u8981\u7684\u662f\u4e0d\u8981\u963b\u585e\u7ebf\u7a0b\u3002&nbsp;<\/p>\n\n\n\n<p>\u8ba9\u6211\u4eec\u6765\u770b\u4e00\u4e2a\u4f8b\u5b50\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;html>\n  &lt;script>\n    alert(\"Does JavaScript show first?\");\n  &lt;\/script>\n  &lt;body>\n    &lt;p>\n      Does HTML show first?\n    &lt;\/p>\n  &lt;\/body>\n&lt;\/html><\/code><\/pre>\n\n\n\n<p>\u5982\u679c\u5728\u6d4f\u89c8\u5668\u4e2d\u52a0\u8f7d\u8be5HTML\u9875\u9762\uff0c\u5219\u4f1a\u53d1\u73b0\u5148\u5f39\u51fa\u8b66\u62a5\uff0c\u7136\u540e\u963b\u6b62HTML\u663e\u793a\u3002\u8fd9\u662f\u56e0\u4e3a\u8be5<code>alert()<\/code>\u51fd\u6570\u4f1a\u4e2d\u6b62JavaScript\u7ebf\u7a0b\u7684\u6267\u884c\uff0c\u76f4\u5230\u7528\u6237\u5c06\u5176\u5173\u95ed\u4e3a\u6b62\u3002\u7b80\u800c\u8a00\u4e4b\uff0c\u5f53JavaScript\u963b\u6b62\u60a8\u7684\u6d4f\u89c8\u5668\u65f6\uff0c\u5c31\u6c38\u8fdc\u4e0d\u4f1a\u5e26\u6765\u826f\u597d\u7684\u7528\u6237\u4f53\u9a8c\u3002&nbsp;<\/p>\n\n\n\n<p>\u597d\u6d88\u606f\u662f\uff0c\u9664\u4e86\u4e00\u4e9b<code>alert()<\/code>\u4e0a\u9762\u7684\u529f\u80fd\u4ecd\u7136\u5b58\u5728\u7684\u9057\u7559\u7279\u6027\u5916\uff0cJavaScript\u662f\u4e00\u79cd\u5f02\u6b65\u8bed\u8a00\u3002&nbsp;<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><a href=\"https:\/\/trailhead.salesforce.com\/content\/learn\/modules\/javascript-essentials-salesforce-developers\/async-js#-----------asynchronous-javascript-is-everywhere--\"><\/a>\u5f02\u6b65JavaScript\u65e0\u5904\u4e0d\u5728<\/h2>\n\n\n\n<p>\u4e3a\u4e86\u5f00\u59cb\u5f02\u6b65\u4e4b\u65c5\uff0c\u8ba9\u6211\u4eec\u91cd\u65b0\u56de\u987e\u4e8b\u4ef6\u548c\u529f\u80fd\u3002\u4ee5\u524d\u6211\u4eec\u770b\u8fc7\u8fd9\u6837\u7684HTML\u548cJavaScript\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;!-- HTML -->\n&lt;button id=\"clicker\">\n\/\/JavaScript\nlet button = document.getElementById(\"clicker\");\nbutton.addEventListener(\"click\", handleClick);<\/code><\/pre>\n\n\n\n<p>\u5728\u6b64\u793a\u4f8b\u4e2d\uff0c\u6211\u4eec\u5c06<code>handleClick<\/code>\u4e8b\u4ef6\u63a7\u4ef6\u6dfb\u52a0\u5230\u6309\u94ae\u53d1\u51fa\u7684click\u4e8b\u4ef6\u4e2d\u3002&nbsp;<\/p>\n\n\n\n<p>\u5728\u90a3\u91cc\uff01\u6211\u4eec\u5df2\u7ecf\u7f16\u5199\u4e86\u4e00\u4e9b\u5f02\u6b65JavaScript\u3002&nbsp;<\/p>\n\n\n\n<p>\u4e8b\u4ef6\u89e6\u53d1\u65f6\uff0c\u6240\u6709\u53d1\u751f\u7684\u4e8b\u60c5\u662f\u5c06\u65b0\u6d88\u606f\u6dfb\u52a0\u5230\u961f\u5217\u4e2d\u3002\u6ca1\u6709\u4e8b\u4ef6\u53ef\u4ee5\u63a5\u7ba1\u7ebf\u7a0b\u3002\u89e6\u53d1\u7684\u6bcf\u4e2a\u4e8b\u4ef6\u90fd\u5fc5\u987b\u8fdb\u5165\u961f\u5217\u5e76\u7b49\u5f85\u8f6e\u6d41\u8fd0\u884c\u3002&nbsp;<\/p>\n\n\n\n<p>\u4e00\u79cd\u8bf4\u660e\u65b9\u6cd5\u662f\u4f7f\u7528<code>setTimeout<\/code>\u51fd\u6570\u3002\u5728\u6b64&nbsp;<a href=\"http:\/\/jsbin.com\/copedan\/2\/edit?js,console\" target=\"_blank\" rel=\"noreferrer noopener\">\u793a\u4f8b<\/a>&nbsp;invoking\u4e2d<code>setTimeout<\/code>\uff0c\u6211\u4eec\u4ee5\u6beb\u79d2\u4e3a\u5355\u4f4d\u4f20\u9012\u4e86\u4e8b\u4ef6\u5904\u7406\u7a0b\u5e8f\u548c\u8ba1\u65f6\u5668\u3002\u8ba1\u65f6\u5668\u5230\u65f6\uff0c\u5b83\u5c06\u89e6\u53d1\uff0c\u5c06\u4e8b\u4ef6\u5904\u7406\u7a0b\u5e8f\u6dfb\u52a0\u5230\u961f\u5217\u4e2d\u3002&nbsp;<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>setTimeout(function(){\n  console.log(\"This comes first\");\n}, 0);\nconsole.log(\"This comes second\");\n\/\/output in console\n\/\/ \"This comes second\"\n\/\/ \"This comes first\"<\/code><\/pre>\n\n\n\n<p>\u5728\u8fd9\u91cc\uff0c\u6211\u4eec\u5c06\u8ba1\u65f6\u5668\u8bbe\u7f6e\u4e3a\u96f6\u3002\u4f46\u8fd9\u5e76\u4e0d\u610f\u5473\u7740\u201c\u7acb\u5373\u81f4\u7535\u201d\u3002\u8fd9\u4ec5\u8868\u793a\u201c\u7acb\u5373\u5c06\u5176\u653e\u5165\u961f\u5217\u4e2d\u201d\u3002\u4f46\u662f\uff0c\u4ee3\u7801\u5757\u672c\u8eab\u7684\u6267\u884c\u9700\u8981\u5b8c\u6210\uff0c\u4ece\u800c\u6e05\u9664\u4e86\u8c03\u7528\u5806\u6808\u3002\u53ea\u6709\u8fd9\u6837\uff0c\u51fd\u6570\u624d\u80fd<code>setTimeout<\/code>&nbsp;\u8f6e\u6d41\u4f7f\u7528\u3002&nbsp;<\/p>\n\n\n\n<p>\u53e6\u4e00\u4e2a\u5e38\u89c1\u7684\u9519\u8bef\u662f\u8ba4\u4e3a\u8ba1\u65f6\u5668\u662f\u4e8b\u4ef6\u5904\u7406\u7a0b\u5e8f\u4f55\u65f6\u89e6\u53d1\u7684\u51c6\u786e\u9884\u6d4b\u5668\uff0c\u4f46\u4e0d\u4e00\u5b9a\u3002\u4e8b\u4ef6\u5904\u7406\u7a0b\u5e8f\u4ecd\u7136\u5fc5\u987b\u7b49\u5f85\u8f6e\u5230\u961f\u5217\u3002\u901a\u8fc7\u6d4b\u91cf\u65f6\u95f4\uff0c\u6211\u4eec\u53ef\u4ee5\u770b\u5230\u8fd9\u4e2a\u00a0\u5728\u884c\u52a8\u3002\u00a0<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>const timer  = function(){\n  let start = Date.now();\n  setTimeout(function(){\n    let end = Date.now();\n    console.log( \"Duration: \" + (end - start) )\n  },1000);\n};\ntimer();\n\/\/ Console output when invoked several times:\n\/\/ \"Duration: 1007\"\n\/\/ \"Duration: 1000\"\n\/\/ \"Duration: 1002\"\n\/\/ \"Duration: 1004\"<\/code><\/pre>\n\n\n\n<p>\u65f6\u95f4\u8bbe\u7f6e\u4e3a\u4e00\u79d2\uff0c\u5e76\u4e14\u5b83\u63a5\u8fd1\u4e8e\u8be5\u65f6\u95f4\u3002\u4f46\u662f\u5f88\u660e\u663e\uff0c\u5c06\u51fd\u6570\u6dfb\u52a0\u5230\u961f\u5217\u7136\u540e\u5728\u6bcf\u6b21\u8c03\u7528\u65f6\u8fd0\u884c\u7684\u901f\u5ea6\u6709\u6240\u4e0d\u540c\u3002&nbsp;<\/p>\n\n\n\n<p>\u73b0\u5728\uff0c\u6211\u4eec\u5df2\u7ecf\u770b\u5230\u4e86\u4e00\u4e9b\u5f02\u6b65\u8c03\u7528\u7684\u793a\u4f8b\uff0c\u6211\u4eec\u53ef\u4ee5\u770b\u770b\u4e00\u4e9b\u5e38\u89c1\u7684\u5f02\u6b65\u6a21\u5f0f\u548c\u6784\u9020\u3002&nbsp;<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><a href=\"https:\/\/trailhead.salesforce.com\/content\/learn\/modules\/javascript-essentials-salesforce-developers\/async-js#-----------callback-pattern--\"><\/a>\u56de\u8c03\u6a21\u5f0f<\/h2>\n\n\n\n<p>\u56de\u8c03\u53ea\u662f\u4e00\u4e2a\u4f20\u9012\u7ed9\u53e6\u4e00\u4e2a\u51fd\u6570\u7684\u51fd\u6570\uff0c\u8be5\u51fd\u6570\u4f1a\u5728\u5c06\u6765\u7684\u67d0\u4e2a\u65f6\u523b\u8c03\u7528\u5b83\u3002&nbsp;<\/p>\n\n\n\n<p>\u56e0\u6b64\uff0c\u5b9e\u9645\u4e0a\uff0c\u6211\u4eec\u5df2\u7ecf\u770b\u5230\u4e86\u5f88\u591a\u56de\u8c03\u3002&nbsp;<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>setTimeout(callback, timer)\nElement.addEventListener(event, callback)\nArray.map(function(item){...})<\/code><\/pre>\n\n\n\n<p>\u8ba9\u6211\u4eec\u5c06\u5176\u5e94\u7528\u4e8e\u81ea\u884c\u8f66\u00a0\u7528\u4f8b\uff0c\u4ee5\u4e86\u89e3\u5982\u4f55\u5b9e\u73b0\u56de\u8c03\u3002\u5f53\u60a8\u6362\u6321\u65f6\uff0c\u5927\u591a\u6570\u60c5\u51b5\u4e0b\u5b83\u90fd\u8d77\u4f5c\u7528\u3002\u4f46\u662f\u5931\u8d25\u7684\u53ef\u80fd\u6027\u4ecd\u7136\u5f88\u5c0f\u3002\u8fd9\u662f\u5f02\u6b65JavaScript\u7684\u7406\u60f3\u65b9\u6848\u3002\u8ba9\u6211\u4eec\u770b\u4e00\u4e0b\u56de\u8c03\u7684\u5916\u89c2\uff0c\u8be5\u56de\u8c03\u63a5\u6536\u6709\u5173\u9f7f\u8f6e\u5982\u4f55\u79fb\u52a8\u7684\u6570\u636e\uff0c\u7136\u540e\u5728\u5b8c\u6210\u65f6\u8c03\u7528\u4f20\u5165\u7684\u51fd\u6570\u3002\u00a0<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Bike.prototype.changeGearAsync = function(shiftObject, callback){\n  let newIndex = shiftObject.currentIndex + shiftObject.changeBy;\n  if (newIndex &lt; 0 || newIndex > shiftObject.maxIndex) {\n    callback(new Error(\"There is a problem\"), null);\n  } else {\n    callback(null, newIndex);\n  }\n};<\/code><\/pre>\n\n\n\n<p>\u8be5\u53c2\u6570<code>callback<\/code>\u5b9e\u9645\u4e0a\u662f\u4e00\u4e2a\u51fd\u6570\u3002\u5982\u679c\u6709\u9519\u8bef\uff0c\u6211\u4eec\u5c06\u8c03\u7528\u5b83\u5e76\u4e3a\u7b2c\u4e00\u4e2a\u53c2\u6570\u8bbe\u7f6e\u8981\u53d1\u9001\u56de\u7684\u4efb\u4f55\u9519\u8bef\u6570\u636e\u3002\u6210\u529f\u540e\uff0c\u6211\u4eec\u5c06\u9519\u8bef\u53c2\u6570\u8bbe\u4e3a\u7a7a\u5e76\u4f20\u56de\u6b63\u786e\u7684\u6570\u636e\u3002\u7136\u540e\uff0c\u6211\u4eec\u53ef\u4ee5\u770b\u5230\u5982\u4f55\u8c03\u7528\u65b0\u7684\u6362\u6863\u529f\u80fd\u3002&nbsp;<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Bike.prototype.changeGear = function(frontOrRear, changeBy) {\n  const shiftIndexName = frontOrRear + \"GearIndex\"\n  const that = this;\n  \/\/contains state change for making the shift\n  let shiftObject = {\n    currentIndex: this[shiftIndexName],\n    maxIndex: this.transmission[frontOrRear + \"GearTeeth\"].length,\n    changeBy: changeBy\n  }\n  \/\/ invoke async function with anonymous callback\n  this.changeGearAsync(shiftObject, function(err, newIndex){\n    if (err) {\n      console.log(\"No Change\");\n    } else {\n      that[shiftIndexName] = newIndex;\n    }\n  });\n};<\/code><\/pre>\n\n\n\n<p>\u56de\u8c03\u6a21\u5f0f\u5df2\u88ab\u5e7f\u6cdb\u63a5\u53d7\u5e76\u5e7f\u6cdb\u4f7f\u7528\uff0c\u4f46\u662f\u5b83\u4e5f\u6709\u4e00\u4e9b\u7f3a\u70b9\u3002\u9996\u5148\uff0c\u5f53\u591a\u4e2a\u56de\u8c03\u94fe\u63a5\u5728\u4e00\u8d77\u65f6\uff0c\u5b83\u4eec\u88ab\u5d4c\u5957\u5728\u53e6\u4e00\u4e2a\u4e2d\u3002\u8fd9\u4f1a\u9020\u6210\u4e0d\u5fc5\u8981\u7684\u590d\u6742\u6027\uff0c\u53ef\u8bfb\u6027\u95ee\u9898\uff0c\u5e76\u4e14\u5728\u9605\u8bfb\u522b\u4eba\u7684\u4ee3\u7801\u65f6\u5f88\u96be\u63a8\u7406\u3002\u6b64\u7f3a\u9677\u79f0\u4e3a<em>\u56de\u8c03\u5730\u72f1<\/em>\u3002\u56de\u8c03\u4e5f\u6ca1\u6709\u9690\u5f0f\u9519\u8bef\u72b6\u6001\uff08\u50cf<code>try\/catch<\/code>\u8fd9\u6837\uff09\u3002\u7531\u5f00\u53d1\u4eba\u5458\u7f16\u5199\u56de\u8c03\u4ee5\u660e\u786e\u67e5\u627e\u5e26\u6709<code>if<\/code>\u6761\u4ef6\u7684\u9519\u8bef\uff0c\u8fd9\u53d6\u51b3\u4e8e\u5f00\u53d1\u4eba\u5458\u3002\u8fd9\u4e9b\u969c\u788d\u5bfc\u81f4\u4e86\u8bfa\u8a00\u7684\u521b\u9020\u3002&nbsp;<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><a href=\"https:\/\/trailhead.salesforce.com\/content\/learn\/modules\/javascript-essentials-salesforce-developers\/async-js#-----------arrow-functions--\"><\/a>\u7bad\u5934\u529f\u80fd<\/h2>\n\n\n\n<p>\u5728\u524d\u9762\u7684\u793a\u4f8b\u4e2d\uff0c\u60a8\u53ef\u80fd\u5df2\u7ecf\u6ce8\u610f\u5230\u4e86\u8fd9\u4e00\u884c\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>const that = this;<\/code><\/pre>\n\n\n\n<p>\u8fd9\u662f\u65e7\u7248JavaScript\u7684\u9057\u7269\u3002\u6211\u4eec\u4ec5\u4ecb\u7ecd\u4e00\u79cd\u65b0\u7684\u51fd\u6570\u8bed\u6cd5\uff1a\u7bad\u5934\u51fd\u6570\u3002\u56de\u60f3\u4e00\u4e0b\u8c03\u7528\u51fd\u6570\u65f6\u4f1a\u53d1\u751f\u4ec0\u4e48\u3002\u5177\u4f53\u6765\u8bf4\uff0c\u5b83\u5c06\u7ed1\u5b9a\u5230\u65b0<code>this<\/code>\u4e0a\u4e0b\u6587\u3002\u4e0e\u533f\u540d\u51fd\u6570\u5173\u95ed\u8303\u56f4\u5185\u7684\u5176\u4ed6\u53d8\u91cf\u4e0d\u540c\uff0cJavaScript&nbsp;<code>this<\/code>\u5b9e\u9645\u4e0a\u5728\u5b9e\u9645\u4e0a\u6211\u4eec\u9700\u8981<code>this<\/code>\u5305\u542b\u51fd\u6570\u65f6\u91cd\u65b0\u7ed1\u5b9a\u3002&nbsp;<\/p>\n\n\n\n<p>\u4e00\u4e2a\u957f\u671f\u7684\u89e3\u51b3\u65b9\u6cd5\u662f\u5206\u914d<code>this<\/code>\u4e00\u4e2a\u65b0\u53d8\u91cf\uff08\u6309\u7167\u60ef\u4f8b\u901a\u5e38\u79f0\u4e3a<code>self<\/code>or&nbsp;<code>that<\/code>\uff09\uff0c\u7136\u540e\u5c06\u4e0a\u4e0b\u6587\u5f15\u7528\u4fdd\u7559\u5728\u95ed\u5305\u4e2d\u3002<\/p>\n\n\n\n<p>\u7bad\u5934\u51fd\u6570\u901a\u8fc7\u4e0d\u91cd\u65b0\u7ed1\u5b9a\u6765\u6d88\u9664\u7f16\u7801\u6280\u5de7\u7684\u8fd9\u4e00\u70b9<code>this<\/code>\u3002\u7bad\u5934\u51fd\u6570\u8bed\u6cd5\u5982\u4e0b\u6240\u793a\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>(arg1, arg2) => {...function body...}<\/code><\/pre>\n\n\n\n<p>\u4f7f\u7528\u7bad\u5934\u529f\u80fd\uff0c\u6211\u4eec\u53ef\u4ee5\u5220\u9664\u8be5<code>that = this<\/code>\u4f4d\u5e76\u5c06\u5176\u8c03\u7528\u66f4\u6539<code>changeGearsAsync<\/code>\u4e3a\u4ee5\u4e0b\u5185\u5bb9\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>  \/\/ the anonymous function is now an arrow function\nthis.changeGearAsync(shiftObject, (err, newIndex)=>{\n  if (err) {\n    console.log(\"No Change\");\n  } else {\n    \/\/ we reference this instead of that\n    this[shiftIndexName] = newIndex;\n  }\n});<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\"><a href=\"https:\/\/trailhead.salesforce.com\/content\/learn\/modules\/javascript-essentials-salesforce-developers\/async-js#-----------promising-stuff--\"><\/a>\u6709\u524d\u9014\u7684\u4e1c\u897f<\/h2>\n\n\n\n<p>\u5f00\u53d1\u4e3a\u5904\u7406\u5f02\u6b65\u4ee3\u7801\u7684\u5e93\u7684\u627f\u8bfa\uff0c\u4f7f\u60a8\u53ef\u4ee5\u66f4\u8f7b\u677e\u5730\u63a8\u65ad\u4ee3\u7801\u6210\u529f\u6216\u5931\u8d25\u7684\u65f6\u95f4\u3002\u5b83\u4eec\u8fd8\u5305\u542b\u5185\u7f6e\u673a\u5236\uff0c\u53ef\u5c06\u4e00\u4e2a\u547c\u53eb\u94fe\u63a5\u5230\u53e6\u4e00\u4e2a\u547c\u53eb\u3002\u6700\u7ec8\uff0c\u7ade\u4e89\u5e93\u5728\u6d4f\u89c8\u5668\u4e2d\u88ab\u6807\u51c6\u5316\u4e3a<code>Promise<\/code>\u5bf9\u8c61\u3002\u8ba9\u6211\u4eec\u53d8\u8eab<code>bike<\/code>\u4e00\u4e2a\u591a&nbsp;<a href=\"http:\/\/jsbin.com\/qoxicip\/5\/edit?js,console\" target=\"_blank\" rel=\"noreferrer noopener\">\u7684\u65f6\u95f4<\/a>\u3002&nbsp;<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Bike.prototype.changeGearAsync = function(shiftObject){\n  return new Promise(\n    (resolve, reject) => {\n      let newIndex = shiftObject.currentIndex + shiftObject.changeBy;\n      if (newIndex &lt; 0 || newIndex > shiftObject.maxIndex) {\n        reject(\"New Index is Invalid: \" + newIndex);\n      } else {\n        resolve(newIndex);\n      }\n    }\n  );\n};<\/code><\/pre>\n\n\n\n<p>\u9996\u5148\uff0c\u66f4\u65b0\u540e\u7684<code>changeGearAsync<\/code>\u51fd\u6570\u63a5\u6536\u6211\u4eec\u4f20\u9012\u7684\u6570\u636e\uff0c\u5e76\u8fd4\u56de\u4e00\u4e2a\u65b0\u7684Promise\u5bf9\u8c61\u3002\u6211\u4eec\u4f20\u5165\u4e00\u4e2a\u53c2\u6570\uff1a\u4e00\u4e2a\u56de\u8c03\u51fd\u6570\uff0c\u5b83\u672c\u8eab\u6709\u4e24\u4e2a\u51fd\u6570\u4f20\u9012\u7ed9\u5b83\uff0c<code>resolve<\/code>\u548c<code>reject<\/code>\u3002&nbsp;<\/p>\n\n\n\n<p>\u5728\u5b9e\u73b0promise\u65f6\uff0c\u60a8\u53ef\u4ee5\u6267\u884c\u56de\u8c03\u51fd\u6570\u4e2d\u6240\u9700\u7684\u4efb\u4f55\u8ba1\u7b97\uff0c\u8bf7\u6c42\u7b49\u3002\u5b8c\u6210\u540e\uff0c\u5982\u679c\u4e00\u5207\u987a\u5229\uff0c\u60a8\u5c06<code>resolve<\/code>\u4f7f\u7528\u8981\u4f20\u9012\u56de\u7684\u6570\u636e\u8fdb\u884c\u8c03\u7528\u3002\u5982\u679c\u9047\u5230\u95ee\u9898\uff0c\u60a8\u53ef\u4ee5\u901a\u8fc7\u8c03\u7528<code>reject<\/code>\u4efb\u4f55\u76f8\u5173\u9519\u8bef\u4f5c\u4e3a\u53c2\u6570\u6765\u5411\u51fd\u6570\u8c03\u7528\u8005\u53d1\u51fa\u4fe1\u53f7\u3002&nbsp;<\/p>\n\n\n\n<p>\u8ba9\u6211\u4eec\u770b\u770b\u6211\u4eec\u73b0\u5728\u5982\u4f55\u4f7f\u7528\u5b83\u3002&nbsp;<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/\/ invoke async function that returns a promise\nthis.changeGearAsync(shiftObject)\n  .then(\n    (newIndex) => {\n      this[shiftIndexName] = newIndex;\n      console.log(this.calculateGearRatio());\n    }\n  )\n  .catch(\n    (err) => {console.log(\"Error: \" + err);}\n  );<\/code><\/pre>\n\n\n\n<p>\u73b0\u5728\uff0c\u6211\u4eec\u6709\u4e86\u4e00\u4e9b\u66f4\u5bb9\u6613\u63a8\u7406\u7684\u4e1c\u897f\u3002\u5982\u679c<code>changeGearAsync<\/code>\u53ef\u884c\uff0c\u5219\u5c06<code>then<\/code>\u51fd\u6570\u4e0e\u4f20\u9012\u7ed9\u5176\u53c2\u6570\u7684\u51fd\u6570\u4e00\u8d77\u8c03\u7528\u3002\u5982\u679c\u6ca1\u6709\uff0c<code>catch<\/code>\u5219\u88ab\u8c03\u7528\u3002&nbsp;<\/p>\n\n\n\n<p>\u5982\u679c\u56de\u8c03\u51fd\u6570\u672c\u8eab\u8fd4\u56de\u7684\u5b9e\u4f8b<code>Promise<\/code>\uff0c\u90a3\u4e48\u4e8b\u60c5\u5c31\u4f1a\u53d8\u5f97\u4ee4\u4eba\u5174\u594b\u3002\u60a8\u53ef\u4ee5\u7b80\u5355\u5730\u5c06\u8fd9\u4e24\u4e2aPromise\u51fd\u6570\u94fe\u63a5\u5728\u4e00\u8d77\u3002\u4e3e\u4f8b\u6765\u8bf4\uff0c\u5982\u679c\u6211\u4eec\u60f3\u6539\u53d8&nbsp;<a href=\"http:\/\/jsbin.com\/qoxicip\/9\/edit?js,console\" target=\"_blank\" rel=\"noreferrer noopener\">\u8fd9\u4e24\u4e2a<\/a>\u524d\u540e\u9f7f\u8f6e\u3002&nbsp;<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Bike.prototype.changeBothGears = function(frontChange, rearChange) {\n  let shiftFront = {\n    currentIndex: this.frontGearIndex,\n    maxIndex: this.transmission.frontGearTeeth.length - 1,\n    changeBy: frontChange\n  };\n  let shiftRear = {\n    currentIndex: this.rearGearIndex,\n    maxIndex: this.transmission.rearGearTeeth.length - 1,\n    changeBy: rearChange\n  };\n  this.changeGearAsync(shiftFront)\n    .then(\n      (newIndex) => {\n        this.frontGearIndex = newIndex;\n        console.log(this.calculateGearRatio());\n        return this.changeGearAsync(shiftRear);\n      }\n    )\n    .then(\n      (newIndex) => {\n        this.rearGearIndex = newIndex;\n        console.log(this.calculateGearRatio());\n      }\n    )\n    .catch(\n      (err) => {console.log(\"Error: \" + err);}\n    );\n  };<\/code><\/pre>\n\n\n\n<p><code>changeBothGears<\/code>\u4e0a\u9762\u7684\u51fd\u6570\u5411\u6211\u4eec\u663e\u793a\u4e86\u5bf9\u7684\u4e24\u4e2a\u8c03\u7528\u7684\u94fe\u63a5<code>changeGearsAsync<\/code>\uff0c\u6bcf\u4e2a\u8c03\u7528\u90fd\u4e0e\u5bf9\u5e94\u4e8e\u524d\u9f7f\u8f6e\u6216\u540e\u9f7f\u8f6e\u7684\u5bf9\u8c61\u76f8\u5173\u3002\u7b2c\u4e00\u6b21\u8c03\u7528\u4e4b\u540e\uff0c\u6211\u4eec\u5728\u7b2c\u4e00\u6b21\u8c03\u7528\u7ed3\u675f\u65f6\u518d\u6b21\u8c03\u7528\u5b83<code>then<\/code>\u3002<code>then<\/code>\u53ef\u4ee5\u5728\u4e0a\u9762\u52a0\u4e0a\u53e6\u4e00\u4e2a\u3002\u4ece\u6839\u672c\u4e0a\u8bb2\uff0c\u6bcf\u5f53\u4e00\u4e2a<code>then<\/code>\u627f\u8bfa\u8fd4\u56de\u65f6\uff0c\u90fd\u53ef\u4ee5\u8ddf\u968f\u53e6\u4e00\u4e2a\u627f\u8bfa\uff0c<code>then<\/code>\u76f4\u5230\u6211\u4eec\u7528\u5c3d\u4e86\u6240\u6709\u94fe\u5f0f\u52a8\u4f5c\u3002 &nbsp;<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><a href=\"https:\/\/trailhead.salesforce.com\/content\/learn\/modules\/javascript-essentials-salesforce-developers\/async-js#-----------asyncawait--\"><\/a>\u5f02\u6b65\/\u7b49\u5f85<\/h2>\n\n\n\n<p>\u5728\u7b7e\u5b57\u4e4b\u524d\uff0c\u503c\u5f97\u4e00\u63d0\u7684\u662f\u5f02\u6b65\u6b66\u5668\u5e93\u4e2d\u7684\u4e00\u4e9b\u65b0\u529f\u80fd\uff1a<code>async<\/code>\u548c<code>await<\/code>\u8fd0\u7b97\u7b26\u3002\u8fd9\u4e9b\u57fa\u4e8epromise\uff0c\u4f7f\u5b83\u4eec\u7684\u4f7f\u7528\u65b9\u5f0f\u4e0e\u540c\u6b65JavaScript\u975e\u5e38\u76f8\u4f3c\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><a href=\"https:\/\/trailhead.salesforce.com\/content\/learn\/modules\/javascript-essentials-salesforce-developers\/async-js#-----------lightning-web-components-and-asynchronous-javascript--\"><\/a>\u95ea\u7535Web\u7ec4\u4ef6\u548c\u5f02\u6b65JavaScript<\/h2>\n\n\n\n<p>\u5229\u7528Lightning Web Components\uff0c\u5f00\u53d1\u4eba\u5458\u53ef\u4ee5\u540c\u65f6\u4f7f\u7528\u57fa\u4e8e\u627f\u8bfa\u7684\u5f02\u6b65\u529f\u80fd\u548c\u5f02\u6b65\/\u7b49\u5f85\u529f\u80fd\u3002\u73b0\u5728\u552f\u4e00\u7684\u5efa\u8bae\u662f\uff0c\u4e3a\u5f00\u53d1\u4eba\u5458\u5728Internet Explorer 11\u4e0a\u4e3a\u7528\u6237\u521b\u5efa\u529f\u80fd\uff0c<code>async<\/code>\/&nbsp;<code>await<\/code>&nbsp;\u5728\u8be5\u6d4f\u89c8\u5668\u4e2d\u672a\u5b9e\u73b0\u3002\u4e0d\u8fc7\uff0c\u8bf7\u653e\u5fc3\uff0c\u60a8\u7684\u4ee3\u7801\u53ef\u4ee5\u4f7f\u7528\u3002\u4f46\u662f\uff0c\u5f53\u5728IE11\u4e2d\u4f7f\u7528async \/ await\u8fd0\u884c\u4efb\u4f55\u5185\u5bb9\u65f6\uff0cLWC\u4f1a\u81ea\u52a8\u4f7f\u7528polyfill\uff0c\u4ee5\u4fbf\u8bed\u6cd5\u6b63\u786e\u8fd0\u884c\u3002\u56e0\u6b64\uff0c\u5982\u679c\u7ecf\u5e38\u4f7f\u7528\uff0cIE11\u7684\u6027\u80fd\u53ef\u80fd\u4f1a\u6709\u6240\u4e0b\u964d\u3002&nbsp;<\/p>\n\n\n\n<p><strong>\u4e0eSalesforce\u4e92\u52a8<\/strong><\/p>\n\n\n\n<p>\u5728Lightning Web Components\u4e2d\u5b9e\u73b0\u4e86\u4f7f\u7528\u5f02\u6b65JavaScript\u7684\u82e5\u5e72\u529f\u80fd\u3002\u5176\u4e2d\u5927\u591a\u6570\u56f4\u7ed5\u4e0e\u670d\u52a1\u5668\u7684\u4ea4\u4e92\u3002\u4e00\u4e2a\u793a\u4f8b\u662f\u53ef\u4ee5\u5728Lightning Web\u7ec4\u4ef6\u4e2d\u5f3a\u5236\u8c03\u7528Apex\u65b9\u6cd5\u7684\u65b9\u6cd5\u3002&nbsp;<\/p>\n\n\n\n<p>\u8003\u8651\u4ee5\u4e0bApex\u7c7b\u548c\u65b9\u6cd5\uff1a&nbsp;<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>public with sharing class ContactController {\n    @AuraEnabled(cacheable=true)\n    public static List&lt;Contact> findContacts(String searchKey) {\n        if (String.isBlank(searchKey)) {\n            return new List&lt;Contact>();\n        }\n    String key = '%' + searchKey + '%';\n    return [SELECT Id, Name, Title, Phone, Email, Picture__c FROM Contact WHERE Name LIKE :key AND Picture__c != null LIMIT 10];\n    }\n...<\/code><\/pre>\n\n\n\n<p>Lightning Web Components\u4f7f\u7528\u57fa\u4e8ePromise\u7684API\u6765\u5c55\u793a\u6b64\u65b9\u6cd5\u3002\u60a8\u53ef\u4ee5\u8fd9\u6837\u8c03\u7528\u5b83\uff1a&nbsp;<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>import { LightningElement, track } from 'lwc';\nimport findContacts from '@salesforce\/apex\/ContactController.findContacts';\nexport default class ApexImperativeMethodWithParams extends LightningElement {\n    @track searchKey = '';\n    @track contacts;\n    @track error;\n    handleSearch() {\n        findContacts({ searchKey: this.searchKey })\n        .then(result => {\n            this.contacts = result;\n            this.error = undefined;\n        })\n        .catch(error => {\n            this.error = error;\n            this.contacts = undefined;\n        });\n    }\n}<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/res.cloudinary.com\/hy4kyit2a\/image\/upload\/doc\/trailhead\/en-usb473bb5ea1b7e61dfb07e6a7e547de6b.gif\" alt=\"\u6ce8\u610f\"\/><\/figure>\n\n\n\n<h4 class=\"wp-block-heading\"><a href=\"https:\/\/trailhead.salesforce.com\/content\/learn\/modules\/javascript-essentials-salesforce-developers\/async-js#note\"><\/a>\u6ce8\u610f<\/h4>\n\n\n\n<p>\u8fd9\u91cc\u6709\u4e00\u4e9b\u8d85\u51fa\u6b64\u6a21\u5757\u8303\u56f4\u7684\u5185\u5bb9\uff0c\u6700\u503c\u5f97\u6ce8\u610f\u7684\u662fES6\u4e2dJavaScript\u6a21\u5757\u7684\u4f7f\u7528\u3002\u8981\u4e86\u89e3\u8fd9\u4e9b\u529f\u80fd\uff0c\u8fd9\u662f\u8003\u8651\u8fdb\u5165\u672c\u6559\u7a0b\u201c\u73b0\u4ee3JavaScript\u5f00\u53d1\u201d\u4e2d\u7684\u4e0b\u4e00\u4e2a\u6a21\u5757\u7684\u7edd\u4f73\u65f6\u673a\u3002\u4f46\u662f\u5728\u60a8\u8fd9\u6837\u505a\u4e4b\u524d\uff0c\u8bf7\u5148\u4e86\u89e3\u4e00\u4e0b\u6b64\u4ee3\u7801\u3002&nbsp;<\/p>\n\n\n\n<p>\u5f53\u6211\u4eec\u79f0\u5176<code>import findContacts\u2026<\/code>\u4e3a\u6807\u51c6\u6a21\u5757\u8bed\u6cd5\u65f6\uff0c\u8be5\u7ec4\u4ef6\u4e2d\u5c06\u5305\u542b\u53e6\u4e00\u4e2a\u6a21\u5757\u7684\u529f\u80fd\u3002\u6211\u4eec\u5728<code>findContacts<\/code>\u8fd9\u91cc\u5c06Apex\u65b9\u6cd5\u5c55\u793a\u4e3a\u540c\u540d\u7684JS\u51fd\u6570\u3002&nbsp;<\/p>\n\n\n\n<p>\u5f53\u6211\u4eec\u5728<code>handleSearch()<\/code>\u51fd\u6570\u4e2d\u8c03\u7528\u5b83\u65f6\uff0cApex\u65b9\u6cd5\u7684\u53c2\u6570\u4f5c\u4e3a\u6587\u5b57\u5bf9\u8c61\u4f20\u9012\uff0c\u7136\u540e\u6211\u4eec\u770b\u5230\u4e86then\u548c<code>catch<\/code>\u51fd\u6570\u7684\u57fa\u4e8epromise\u7684\u8bed\u6cd5\u3002<\/p>\n\t\t","protected":false},"excerpt":{"rendered":"<p>\u5b66\u4e60\u76ee\u6807 \u5b8c\u6210\u672c\u5355\u5143\u540e\uff0c\u60a8\u5c06\u80fd\u591f\uff1a \u8bc6\u522bJavaScript\u4e2d\u91cd\u8981\u7684\u5f02\u6b65\u529f\u80fd\u3002 \u4f7f\u7528setTimeout\u5f02\u6b65\u8c03 &hellip; <a href=\"http:\/\/www.ponybai.com\/?p=2425\" class=\"more-link\">\u7ee7\u7eed\u9605\u8bfb<span class=\"screen-reader-text\">Salesforce\u5f00\u53d1\u4eba\u5458\u7684JavaScript\u6280\u80fd-\u7f16\u5199\u5f02\u6b65JavaScript<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[56],"tags":[],"class_list":["post-2425","post","type-post","status-publish","format-standard","hentry","category-lwcjavascript"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v21.7 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Salesforce\u5f00\u53d1\u4eba\u5458\u7684JavaScript\u6280\u80fd-\u7f16\u5199\u5f02\u6b65JavaScript - \u767d\u767d\u968f\u7b14<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"http:\/\/www.ponybai.com\/?p=2425\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Salesforce\u5f00\u53d1\u4eba\u5458\u7684JavaScript\u6280\u80fd-\u7f16\u5199\u5f02\u6b65JavaScript - \u767d\u767d\u968f\u7b14\" \/>\n<meta property=\"og:description\" content=\"\u5b66\u4e60\u76ee\u6807 \u5b8c\u6210\u672c\u5355\u5143\u540e\uff0c\u60a8\u5c06\u80fd\u591f\uff1a \u8bc6\u522bJavaScript\u4e2d\u91cd\u8981\u7684\u5f02\u6b65\u529f\u80fd\u3002 \u4f7f\u7528setTimeout\u5f02\u6b65\u8c03 &hellip; \u7ee7\u7eed\u9605\u8bfbSalesforce\u5f00\u53d1\u4eba\u5458\u7684JavaScript\u6280\u80fd-\u7f16\u5199\u5f02\u6b65JavaScript\" \/>\n<meta property=\"og:url\" content=\"http:\/\/www.ponybai.com\/?p=2425\" \/>\n<meta property=\"og:site_name\" content=\"\u767d\u767d\u968f\u7b14\" \/>\n<meta property=\"article:published_time\" content=\"2020-06-25T15:30:30+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/res.cloudinary.com\/hy4kyit2a\/image\/upload\/doc\/trailhead\/en-usb473bb5ea1b7e61dfb07e6a7e547de6b.gif\" \/>\n<meta name=\"author\" content=\"ponybai\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"ponybai\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"http:\/\/www.ponybai.com\/?p=2425#article\",\"isPartOf\":{\"@id\":\"http:\/\/www.ponybai.com\/?p=2425\"},\"author\":{\"name\":\"ponybai\",\"@id\":\"http:\/\/www.ponybai.com\/#\/schema\/person\/935c7592c850c65e1e5eba4530dbf883\"},\"headline\":\"Salesforce\u5f00\u53d1\u4eba\u5458\u7684JavaScript\u6280\u80fd-\u7f16\u5199\u5f02\u6b65JavaScript\",\"datePublished\":\"2020-06-25T15:30:30+00:00\",\"dateModified\":\"2020-06-25T15:30:30+00:00\",\"mainEntityOfPage\":{\"@id\":\"http:\/\/www.ponybai.com\/?p=2425\"},\"wordCount\":101,\"publisher\":{\"@id\":\"http:\/\/www.ponybai.com\/#\/schema\/person\/935c7592c850c65e1e5eba4530dbf883\"},\"articleSection\":[\"LWC\u4e2d\u7684Javascript\"],\"inLanguage\":\"zh-Hans\"},{\"@type\":\"WebPage\",\"@id\":\"http:\/\/www.ponybai.com\/?p=2425\",\"url\":\"http:\/\/www.ponybai.com\/?p=2425\",\"name\":\"Salesforce\u5f00\u53d1\u4eba\u5458\u7684JavaScript\u6280\u80fd-\u7f16\u5199\u5f02\u6b65JavaScript - \u767d\u767d\u968f\u7b14\",\"isPartOf\":{\"@id\":\"http:\/\/www.ponybai.com\/#website\"},\"datePublished\":\"2020-06-25T15:30:30+00:00\",\"dateModified\":\"2020-06-25T15:30:30+00:00\",\"breadcrumb\":{\"@id\":\"http:\/\/www.ponybai.com\/?p=2425#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"http:\/\/www.ponybai.com\/?p=2425\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"http:\/\/www.ponybai.com\/?p=2425#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"http:\/\/www.ponybai.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Salesforce\u5f00\u53d1\u4eba\u5458\u7684JavaScript\u6280\u80fd-\u7f16\u5199\u5f02\u6b65JavaScript\"}]},{\"@type\":\"WebSite\",\"@id\":\"http:\/\/www.ponybai.com\/#website\",\"url\":\"http:\/\/www.ponybai.com\/\",\"name\":\"\u767d\u767d\u968f\u7b14\",\"description\":\"Salesforce\u5b98\u65b9\u8bb2\u5e08\",\"publisher\":{\"@id\":\"http:\/\/www.ponybai.com\/#\/schema\/person\/935c7592c850c65e1e5eba4530dbf883\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"http:\/\/www.ponybai.com\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"zh-Hans\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"http:\/\/www.ponybai.com\/#\/schema\/person\/935c7592c850c65e1e5eba4530dbf883\",\"name\":\"ponybai\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"http:\/\/www.ponybai.com\/#\/schema\/person\/image\/\",\"url\":\"http:\/\/www.ponybai.com\/wp-content\/uploads\/2025\/03\/cropped-Ihsans-WeChatQR.jpg\",\"contentUrl\":\"http:\/\/www.ponybai.com\/wp-content\/uploads\/2025\/03\/cropped-Ihsans-WeChatQR.jpg\",\"width\":248,\"height\":248,\"caption\":\"ponybai\"},\"logo\":{\"@id\":\"http:\/\/www.ponybai.com\/#\/schema\/person\/image\/\"},\"sameAs\":[\"http:\/\/121.37.188.161\"],\"url\":\"http:\/\/www.ponybai.com\/?author=1\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Salesforce\u5f00\u53d1\u4eba\u5458\u7684JavaScript\u6280\u80fd-\u7f16\u5199\u5f02\u6b65JavaScript - \u767d\u767d\u968f\u7b14","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"http:\/\/www.ponybai.com\/?p=2425","og_locale":"zh_CN","og_type":"article","og_title":"Salesforce\u5f00\u53d1\u4eba\u5458\u7684JavaScript\u6280\u80fd-\u7f16\u5199\u5f02\u6b65JavaScript - \u767d\u767d\u968f\u7b14","og_description":"\u5b66\u4e60\u76ee\u6807 \u5b8c\u6210\u672c\u5355\u5143\u540e\uff0c\u60a8\u5c06\u80fd\u591f\uff1a \u8bc6\u522bJavaScript\u4e2d\u91cd\u8981\u7684\u5f02\u6b65\u529f\u80fd\u3002 \u4f7f\u7528setTimeout\u5f02\u6b65\u8c03 &hellip; \u7ee7\u7eed\u9605\u8bfbSalesforce\u5f00\u53d1\u4eba\u5458\u7684JavaScript\u6280\u80fd-\u7f16\u5199\u5f02\u6b65JavaScript","og_url":"http:\/\/www.ponybai.com\/?p=2425","og_site_name":"\u767d\u767d\u968f\u7b14","article_published_time":"2020-06-25T15:30:30+00:00","og_image":[{"url":"https:\/\/res.cloudinary.com\/hy4kyit2a\/image\/upload\/doc\/trailhead\/en-usb473bb5ea1b7e61dfb07e6a7e547de6b.gif"}],"author":"ponybai","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"ponybai","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"3 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"http:\/\/www.ponybai.com\/?p=2425#article","isPartOf":{"@id":"http:\/\/www.ponybai.com\/?p=2425"},"author":{"name":"ponybai","@id":"http:\/\/www.ponybai.com\/#\/schema\/person\/935c7592c850c65e1e5eba4530dbf883"},"headline":"Salesforce\u5f00\u53d1\u4eba\u5458\u7684JavaScript\u6280\u80fd-\u7f16\u5199\u5f02\u6b65JavaScript","datePublished":"2020-06-25T15:30:30+00:00","dateModified":"2020-06-25T15:30:30+00:00","mainEntityOfPage":{"@id":"http:\/\/www.ponybai.com\/?p=2425"},"wordCount":101,"publisher":{"@id":"http:\/\/www.ponybai.com\/#\/schema\/person\/935c7592c850c65e1e5eba4530dbf883"},"articleSection":["LWC\u4e2d\u7684Javascript"],"inLanguage":"zh-Hans"},{"@type":"WebPage","@id":"http:\/\/www.ponybai.com\/?p=2425","url":"http:\/\/www.ponybai.com\/?p=2425","name":"Salesforce\u5f00\u53d1\u4eba\u5458\u7684JavaScript\u6280\u80fd-\u7f16\u5199\u5f02\u6b65JavaScript - \u767d\u767d\u968f\u7b14","isPartOf":{"@id":"http:\/\/www.ponybai.com\/#website"},"datePublished":"2020-06-25T15:30:30+00:00","dateModified":"2020-06-25T15:30:30+00:00","breadcrumb":{"@id":"http:\/\/www.ponybai.com\/?p=2425#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["http:\/\/www.ponybai.com\/?p=2425"]}]},{"@type":"BreadcrumbList","@id":"http:\/\/www.ponybai.com\/?p=2425#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"http:\/\/www.ponybai.com\/"},{"@type":"ListItem","position":2,"name":"Salesforce\u5f00\u53d1\u4eba\u5458\u7684JavaScript\u6280\u80fd-\u7f16\u5199\u5f02\u6b65JavaScript"}]},{"@type":"WebSite","@id":"http:\/\/www.ponybai.com\/#website","url":"http:\/\/www.ponybai.com\/","name":"\u767d\u767d\u968f\u7b14","description":"Salesforce\u5b98\u65b9\u8bb2\u5e08","publisher":{"@id":"http:\/\/www.ponybai.com\/#\/schema\/person\/935c7592c850c65e1e5eba4530dbf883"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"http:\/\/www.ponybai.com\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"zh-Hans"},{"@type":["Person","Organization"],"@id":"http:\/\/www.ponybai.com\/#\/schema\/person\/935c7592c850c65e1e5eba4530dbf883","name":"ponybai","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"http:\/\/www.ponybai.com\/#\/schema\/person\/image\/","url":"http:\/\/www.ponybai.com\/wp-content\/uploads\/2025\/03\/cropped-Ihsans-WeChatQR.jpg","contentUrl":"http:\/\/www.ponybai.com\/wp-content\/uploads\/2025\/03\/cropped-Ihsans-WeChatQR.jpg","width":248,"height":248,"caption":"ponybai"},"logo":{"@id":"http:\/\/www.ponybai.com\/#\/schema\/person\/image\/"},"sameAs":["http:\/\/121.37.188.161"],"url":"http:\/\/www.ponybai.com\/?author=1"}]}},"_links":{"self":[{"href":"http:\/\/www.ponybai.com\/index.php?rest_route=\/wp\/v2\/posts\/2425","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.ponybai.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.ponybai.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.ponybai.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.ponybai.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2425"}],"version-history":[{"count":0,"href":"http:\/\/www.ponybai.com\/index.php?rest_route=\/wp\/v2\/posts\/2425\/revisions"}],"wp:attachment":[{"href":"http:\/\/www.ponybai.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2425"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.ponybai.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2425"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.ponybai.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2425"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}