{"id":8186,"date":"2024-06-19T14:01:01","date_gmt":"2024-06-19T06:01:01","guid":{"rendered":""},"modified":"2024-06-19T14:01:01","modified_gmt":"2024-06-19T06:01:01","slug":"\u5c0f\u7a0b\u5e8f\u4e0a\u7ebf\u9700\u8981\u4ec0\u4e48\u6761\u4ef6_\u5c0f\u7a0b\u5e8f\u4e0a\u7ebf\u9700\u8981\u4ec0\u4e48\u6761\u4ef6","status":"publish","type":"post","link":"https:\/\/mushiming.com\/8186.html","title":{"rendered":"\u5c0f\u7a0b\u5e8f\u4e0a\u7ebf\u9700\u8981\u4ec0\u4e48\u6761\u4ef6_\u5c0f\u7a0b\u5e8f\u4e0a\u7ebf\u9700\u8981\u4ec0\u4e48\u6761\u4ef6"},"content":{"rendered":"

\n <\/path> \n<\/svg> <\/p>\n

\u600e\u4e48\u7ed5\u8fc7\u5fae\u4fe1\u5c0f\u7a0b\u5e8f\u4e0a\u7ebf\u5ba1\u6838(\u4e0d\u597d\u7528\u56de\u6765\u5410\u69fd\u6211)<\/h2>\n<\/p>\n
\n

<\/h4>\n
    \n
  • \u600e\u4e48\u7ed5\u8fc7\u5fae\u4fe1\u5c0f\u7a0b\u5e8f\u4e0a\u7ebf\u5ba1\u6838(\u4e0d\u597d\u7528\u56de\u6765\u5410\u69fd\u6211)<\/li>\n
  • \n
      \n
    • \u524d\u8a00<\/li>\n
    • \u65b9\u6848\u4e00<\/li>\n
    • \u65b9\u6848\u4e8c(\u63a8\u8350)<\/li>\n
    • \u4ee3\u7801<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/div>\n

      \u524d\u8a00<\/h3>\n

      \u5f88\u591a\u5f00\u53d1\u8005\u5728\u5f00\u53d1\u9879\u76ee\u7684\u65f6\u5019\u53d1\u73b0\u4e0a\u7ebf\u5fae\u4fe1\u5c0f\u7a0b\u5e8f\u6700\u96be\u7684\u4e0d\u662f\u5f00\u53d1\u9636\u6bb5,\u800c\u662f\u5fae\u4fe1\u5ba1\u6838\u673a\u5236.\u56e0\u4e3a\u5fae\u4fe1\u4e3a\u4e86\u81ea\u8eab\u5e73\u53f0\u89c4\u907f\u6cd5\u5f8b\u98ce\u9669,\u5f00\u53d1\u7684\u5f88\u591a\u529f\u80fd\u9700\u8981\u63d0\u4f9b\u76f8\u5173\u7684\u8bc1\u4ef6\u6216\u8005\u8d44\u8d28,\u4f46\u662f\u76f8\u5173\u7684\u8d44\u8d28\u529e\u7406\u96be\u5ea6\u5927,\u6216\u8005\u4e00\u822c\u7684\u516c\u53f8\u6839\u672c\u529e\u4e0d\u4e0b\u6765.\u90a3\u4e48\u7ed5\u8fc7\u5ba1\u6838\u5c31\u662f\u4e00\u4e2a\u5f88\u91cd\u8981\u7684\u4e0a\u7ebf\u6280\u5de7.<\/p>\n

      \u5410\u69fd\u4e00\u4e0b\uff0c\u5fae\u4fe1\u5ba1\u6838\u5bf9\u4e8ezf\u9879\u76ee\u5ba1\u6838\u529b\u5ea6\u4f1a\u5f88\u4f4e\uff0c\u6211\u8bb0\u5f97\u6700\u5feb\u7684\u4e00\u6b21\u5ba1\u6838\u662f\u4e0d\u523030s\uff0c\u6ca1\u9519\u5c31\u662f\u4e0d\u5230\u534a\u5206\u949f\uff0c\u5fae\u4fe1\u901a\u77e5\u5c31\u544a\u77e5\u5ba1\u6838\u901a\u8fc7\uff0c\u6211\u4e0d\u77e5\u9053\u662f\u4e0d\u662f\u5ba1\u6838\u4eba\u5458\u6478\u9c7c\u4e86\uff0c\u6211\u60f3\u5e94\u8be5\u662f\u6ca1\u6709\u8ba4\u771f\u770b\u7684\u2026<\/p>\n

      \u65b9\u6848\u4e00<\/h3>\n

      \u7f51\u4e0a\u5f88\u591a\u65b9\u6848\u90fd\u662f\u901a\u8fc7\u540e\u53f0\u8bbe\u7f6e\u4e00\u4e2a\u72b6\u6001,\u5ba1\u6838\u7684\u65f6\u5019\u5c31\u5f00\u7740,\u8ba9\u5ba1\u6838\u770b\u5230\u51c6\u5907\u597d\u7684\u9875\u9762,\u5ba1\u6838\u8fc7\u4e86\u5c31\u5173\u4e86.
      \u8fd9\u79cd\u5f62\u5f0f\u6765\u901a\u8fc7\u5ba1\u6838\u6709\u4e00\u4e2a\u7f3a\u70b9\u5c31\u662f\u5728\u8fd9\u4e2a\u671f\u95f4,\u6b63\u5e38\u7528\u6237\u8bbf\u95ee\u5c31\u4f1a\u51fa\u73b0\u5ba1\u6838\u7684\u9875\u9762.\u8fd9\u4e2a\u5c31\u5f88\u96be\u53d7\u4e86.<\/p>\n

      \u5efa\u8bae\u662f\u901a\u8fc7\u63a5\u53e3\u8bbe\u7f6e\u4e24\u4e2a\u53d8\u91cf,\u6bcf\u6b21\u4f7f\u7528\u4e00\u4e2a\u53d8\u91cf,\u4e0b\u6b21\u4f7f\u7528\u53e6\u5916\u4e00\u4e2a\u53d8\u91cf,\u4ea4\u66ff\u4f7f\u7528,\u8fd9\u6837\u53ef\u4ee5\u907f\u5f00\u5728\u5ba1\u6838\u671f\u95f4\u8ba9\u6b63\u5e38\u7528\u6237\u770b\u5230\u5ba1\u6838\u9875\u9762\u7684\u60c5\u51b5<\/p>\n

      \u65b9\u6848\u4e8c(\u63a8\u8350)<\/h3>\n

      \u4e0b\u9762\u8fd9\u4e2a\u662f\u53ef\u4ee5\u65e0\u7f1d\u5207\u6362\u7684\u65b9\u5f0f,\u4e0d\u4f1a\u8ba9\u7528\u6237\u6709\u6240\u611f\u77e5\u5c31\u53ef\u4ee5\u901a\u8fc7\u5ba1\u6838.
      \u65b9\u6848\u4e00\u5ba1\u6838\u9636\u6bb5\u7528\u6237\u65e0\u6cd5\u6b63\u5e38\u8bbf\u95ee\u9879\u76ee,\u90a3\u4e48\u6211\u4eec\u8003\u8651\u5c31\u8ba9\u7528\u6237\u65e0\u611f\u77e5\u7684\u901a\u8fc7\u5ba1\u6838<\/p>\n

      \u6211\u5148\u8bf4\u4e00\u4e0b\u5fae\u4fe1\u5ba1\u6838\u7684\u673a\u5236,\u4e0d\u8981\u95ee\u662f\u54ea\u91cc\u6765\u7684,\u56e2\u961f\u6478\u7d22\u4e86\u597d\u51e0\u5e74,\u8bf4\u591a\u4e86\u90fd\u662f\u6cea(\u8fd9\u4e2a\u5f88\u91cd\u8981)<\/strong>
      1.\u5fae\u4fe1\u5ba1\u6838\u4eba\u5458\u67e5\u770b\u7684\u7248\u672c\u662f\u5f00\u53d1\u7248\u672c.<\/strong>,\u4e0d\u770b\u6b63\u5f0f\u7248\u672c<\/strong>\u548c\u4f53\u9a8c\u7248\u672c<\/strong>.
      2.\u5fae\u4fe1\u5ba1\u6838\u7684\u65f6\u95f4\u4e00\u822c\u57281\u4e2a\u5c0f\u65f6\u52301\u5929\u4e0d\u7b49,\u4e0b\u9762\u662f\u5927\u6982\u7684\u65f6\u95f4:<\/p>\n

      \u975e\u5de5\u4f5c\u65e5\u5ba1\u6838\u6700\u5feb|1\u4e2a\u5c0f\u65f6\u5185
      \u5de5\u4f5c\u65e5\u4e0b\u5348\u52306\u70b9\u8fd9\u6bb5\u65f6\u95f4\u5ba1\u6838\u4f1a\u5f88\u5feb|1\u5c0f\u65f6-2\u5c0f\u65f6
      \u5de5\u4f5c\u65e56\u70b9\u5230\u51cc\u6668\u65f6\u95f4\u4e0d\u56fa\u5b9a|1-6\u5c0f\u65f6\u4e0d\u7b49
      \u51cc\u6668\u8fc7\u540e\u5ba1\u6838\u65f6\u95f4\u4f1a\u62c9\u5f88\u957f|\u6b63\u5e38\u7b2c\u4e8c\u5929\u4e0a\u5348\u4f1a\u5ba1\u6838<\/p>\n

      3.\u5fae\u4fe1\u56e0\u4e3a\u5ba1\u6838\u4eba\u5458\u7684\u4e0d\u540c,\u5ba1\u6838\u529b\u5ea6\u4e0d\u4e00,\u6709\u65f6\u5019\u5f88\u5bb9\u6613\u901a\u8fc7,\u6709\u65f6\u5019\u4f1a\u5361\u4f60\u5f88\u4e45.\u5de5\u4f5c\u65e5\u5ba1\u6838\u4e00\u822c\u4f1a\u5bb9\u6613\u8fc7,\u5468\u516d,\u5468\u5929\u53d1\u5e03\u7684\u8bdd,\u5ba1\u6838\u4eba\u5458\u4f1a\u5ba1\u6838\u6bd4\u8f83\u4e25\u683c,\u6bd4\u5982\u7528\u4e8e\u5ba1\u6838\u7684\u9875\u9762\u5982\u679c\u592a\u7b80\u5355\u4f1a\u8ba4\u4e3a\u662fdome,\u6216\u8005\u4f1a\u4f7f\u7528\u8def\u7531\u8df3\u8f6c\u5176\u4ed6\u9875\u9762\u9010\u4e00\u5ba1\u6838.\u603b\u7ed3\u5c31\u662f\u5ba1\u6838\u4e0d\u5fd9\u7684\u65f6\u5019\u4f1a\u5f88\u86cb\u75bc\u7684\u53bb\u62a0\u7ec6\u8282,\u867d\u7136\u540e\u7eed\u4fee\u6539\u90fd\u53ef\u4ee5\u5904\u7406,\u4f46\u8fc7\u7a0b\u5f88\u75db\u82e6.<\/p>\n

      \u91cd\u70b9\u6765\u4e86<\/strong>:\u5fae\u4fe1\u5c0f\u7a0b\u5e8f\u63d0\u4f9b\u53ef\u4ee5\u67e5\u770b\u662f\u7ebf\u4e0a\u7248\u672c\u7684\u8fd8\u662f\u5f00\u53d1\u7248\u672c\u7684api: wx.getAccountInfoSync()<\/strong><\/p>\n

      \u901a\u8fc7wx.getAccountInfoSync()\u83b7\u53d6\u662f\u4f53\u9a8c\u7248\u672c\u8fd8\u662f\u6b63\u5f0f\u7248\u672c,\u901a\u8fc7\u72b6\u6001\u5224\u65ad,\u5199\u4e00\u4e2a\u7b80\u5355\u5ba1\u6838\u9875\u9762,\u7ed9\u5ba1\u6838\u4eba\u5458\u770b\u5c31\u884c\u4e86.\u5ba1\u6838\u7684\u9875\u9762\u8981\u6709\u4e00\u5b9a\u7684\u529f\u80fd,\u592a\u7b80\u5355\u4f1a\u8ba4\u5b9a\u4e3adome\u9875\u9762.
      \u8fd9\u6837\u5c31\u7ed5\u8fc7\u5ba1\u6838\u4e86.<\/p>\n

      \u4ee3\u7801<\/h3>\n

      \u65b0\u5efaonlineCompoenet\u7684component\u7ec4\u4ef6\u9875\u9762,\u8fd9\u4e2a\u7ec4\u4ef6\u7528\u4e8e\u7ed5\u8fc7\u5fae\u4fe1\u5ba1\u6838<\/p>\n

      \u5ba1\u6838\u7ec4\u4ef6 onlineCompoenet.js<\/p>\n

      const<\/span> app =<\/span> getApp<\/span>(<\/span>)<\/span> Component<\/span>(<\/span>{ \n   <\/span> \/** * \u7ec4\u4ef6\u7684\u5c5e\u6027\u5217\u8868 *\/<\/span> properties<\/span>:<\/span> { \n   <\/span> }<\/span>,<\/span> lifetimes<\/span>:<\/span> { \n   <\/span> \/\/ \u751f\u547d\u5468\u671f\u51fd\u6570\uff0c\u53ef\u4ee5\u4e3a\u51fd\u6570\uff0c\u6216\u4e00\u4e2a\u5728methods\u6bb5\u4e2d\u5b9a\u4e49\u7684\u65b9\u6cd5\u540d<\/span> attached<\/span>:<\/span> function<\/span> (<\/span>)<\/span> { \n   <\/span> const<\/span> that =<\/span> this<\/span>;<\/span> const<\/span> accountInfo =<\/span> wx.<\/span>getAccountInfoSync<\/span>(<\/span>)<\/span>;<\/span> \/\/ develop \u5f00\u53d1\u7248 <\/span> accountInfo.<\/span>miniProgram.<\/span>envVersion =<\/span> 'release'<\/span>;<\/span> \/\/\u4e0a\u7ebf\u5ba1\u6838\u7684\u65f6\u5019\u5c31\u6ce8\u91ca\u6389\u8fd9\u6bb5\u4ee3\u7801\uff0c\u5f00\u53d1\u65f6\u5c31\u4fdd\u7559<\/span> if<\/span> (<\/span>accountInfo.<\/span>miniProgram.<\/span>envVersion ===<\/span> 'release'<\/span>)<\/span> { \n   <\/span> that.<\/span>setData<\/span>(<\/span>{ \n   <\/span> showComponenet<\/span>:<\/span> false<\/span>,<\/span> }<\/span>)<\/span>;<\/span> }<\/span> else<\/span> { \n   <\/span> app.<\/span>globalData.<\/span>isOnline =<\/span> true<\/span>;<\/span> that.<\/span>setData<\/span>(<\/span>{ \n   <\/span> showComponenet<\/span>:<\/span> true<\/span> }<\/span>)<\/span>;<\/span> wx.<\/span>setNavigationBarTitle<\/span>(<\/span>{ \n   <\/span> title<\/span>:<\/span> '\u5217\u8868'<\/span>,<\/span> }<\/span>)<\/span>;<\/span> try<\/span> { \n   <\/span> wx.<\/span>hideTabBar<\/span>(<\/span>{ \n   <\/span> fail<\/span>:<\/span> function<\/span> (<\/span>)<\/span> { \n   <\/span> setTimeout<\/span>(<\/span>function<\/span> (<\/span>)<\/span> { \n   <\/span> \/\/ \u505a\u4e86\u4e2a\u5ef6\u65f6\u91cd\u8bd5\u4e00\u6b21\uff0c\u4f5c\u4e3a\u4fdd\u5e95\u3002<\/span> wx.<\/span>hideTabBar<\/span>(<\/span>)<\/span> }<\/span>,<\/span> 500<\/span>)<\/span> }<\/span> }<\/span>)<\/span>;<\/span> }<\/span> catch<\/span> (<\/span>error)<\/span> { \n   <\/span> }<\/span> }<\/span> }<\/span>,<\/span> moved<\/span>:<\/span> function<\/span> (<\/span>)<\/span> { \n   <\/span>}<\/span>,<\/span> detached<\/span>:<\/span> function<\/span> (<\/span>)<\/span> { \n   <\/span>}<\/span>,<\/span> }<\/span>,<\/span> \/** * \u7ec4\u4ef6\u7684\u521d\u59cb\u6570\u636e *\/<\/span> data<\/span>:<\/span> { \n   <\/span> showComponenet<\/span>:<\/span>false<\/span> }<\/span>,<\/span> \/** * \u7ec4\u4ef6\u7684\u65b9\u6cd5\u5217\u8868 *\/<\/span> methods<\/span>:<\/span> { \n   <\/span> }<\/span> }<\/span>)<\/span> <\/code><\/pre>\n

      \u5ba1\u6838\u7ec4\u4ef6 onlineCompoenet.wxml \u5ba1\u6838\u7ec4\u4ef6\u7684\u5185\u5bb9\u6700\u597d\u662f\u4ecb\u7ecd\u6027\u8d28\u7684\u5185\u5bb9,\u6bd4\u5982\u5b98\u7f51\u4ecb\u7ecd,\u4ea7\u54c1\u4ecb\u7ecd\u7b49,\u8fd9\u79cd\u9875\u9762\u8fd8\u9700\u8981\u505a\u4e00\u4e9b\u4ea4\u4e92\u7684\u529f\u80fd,\u9632\u6b62\u5ba1\u6838\u8ba4\u4e3a\u9875\u9762\u8fc7\u4e8e\u7b80\u5355\u4e0d\u7ed9\u901a\u8fc7,\u5efa\u8bae\u505a\u4e00\u4e9b\u7b80\u5355\u7684\u4e8c\u7ea7\u9875\u6216\u8005\u5730\u56fe,\u7535\u8bdd\u7b49\u90fd\u53ef\u4ee5\u8003\u8651\u52a0\u4e0a.<\/p>\n

      <<\/span>view<\/span> wx:<\/span>if<\/span>=<\/span>\"<\/span>{ \n    {showComponenet}}\"<\/span><\/span> class<\/span>=<\/span>\"<\/span>recommend_null\"<\/span><\/span>><\/span><\/span> <\/<\/span>view<\/span>><\/span><\/span> <\/code><\/pre>\n

      \u5728app.json\u5f15\u5165\u5168\u5c40\u7ec4\u4ef6\u4e2d,\u8fd9\u6837\u4efb\u4f55\u9875\u9762\u90fd\u53ef\u4ee5\u4f7f\u7528\u8fd9\u4e2a\u7ec4\u5efa\u4e86<\/p>\n

       \"usingComponents\"<\/span>:<\/span> { \n   <\/span> \"reviewCompoenent\"<\/span>:<\/span> \"\/components\/onlineComponent\/onlineCompoenet\"<\/span> }<\/span>,<\/span> <\/code><\/pre>\n

      \u5728index.wxml\u4e2d\u52a0\u4e0a\u7ec4\u4ef6\u5c31\u53ef\u4ee5\u4e86<\/p>\n

       <<\/span>reviewCompoenent<\/span> \/><\/span><\/span> <\/code><\/pre>\n

      wx.getAccountInfoSync()
      \"\u5c0f\u7a0b\u5e8f\u4e0a\u7ebf\u9700\u8981\u4ec0\u4e48\u6761\u4ef6_\u5c0f\u7a0b\u5e8f\u4e0a\u7ebf\u9700\u8981\u4ec0\u4e48\u6761\u4ef6<\/p>\n

      \u70b9\u51fb\u8fd9\u91cc\u53ef\u4ee5\u770b\u5176\u4ed6\u4eba\u7684\u63d0\u95ee<\/p>\n

      \u795d\u5927\u5bb6\u987a\u5229\u53d1\u5e03\u4e0a\u7ebf\u9879\u76ee,\u6709\u7528\u7684\u4e00\u952e\u4e09\u8fde\u5427<\/p>\n","protected":false},"excerpt":{"rendered":"\u5c0f\u7a0b\u5e8f\u4e0a\u7ebf\u9700\u8981\u4ec0\u4e48\u6761\u4ef6_\u5c0f\u7a0b\u5e8f\u4e0a\u7ebf\u9700\u8981\u4ec0\u4e48\u6761\u4ef6\u5f88\u591a\u5f00\u53d1\u8005\u5728\u5f00\u53d1\u9879\u76ee\u7684\u65f6\u5019\u53d1\u73b0\u4e0a\u7ebf\u5fae\u4fe1\u5c0f\u7a0b\u5e8f\u6700\u96be\u7684\u4e0d\u662f\u5f00\u53d1\u9636\u6bb5,\u800c\u662f\u5fae\u4fe1...","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"_links":{"self":[{"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/posts\/8186"}],"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=8186"}],"version-history":[{"count":0,"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/posts\/8186\/revisions"}],"wp:attachment":[{"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/media?parent=8186"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/categories?post=8186"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/tags?post=8186"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}