{"id":33393,"date":"2024-11-25T16:41:13","date_gmt":"2024-11-25T08:41:13","guid":{"rendered":"https:\/\/fwq.ai\/blog\/33393\/"},"modified":"2024-11-25T16:41:13","modified_gmt":"2024-11-25T08:41:13","slug":"%e7%94%a8mpvue%e5%bc%80%e5%8f%91%e5%be%ae%e4%bf%a1%e5%b0%8f%e7%a8%8b%e5%ba%8f%e5%9f%ba%e7%a1%80%e7%9f%a5%e8%af%86","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/33393\/","title":{"rendered":"\u7528mpvue\u5f00\u53d1\u5fae\u4fe1\u5c0f\u7a0b\u5e8f\u57fa\u7840\u77e5\u8bc6"},"content":{"rendered":"<h2><span style=\"font-size: 14px\">\u4e00\u3001mpvue\u7b80\u4ecb<\/span><\/h2>\n<blockquote><p>\n  mpvue \u662f\u4e00\u4e2a\u4f7f\u7528 Vue.js \u5f00\u53d1\u5c0f\u7a0b\u5e8f\u7684\u524d\u7aef\u6846\u67b6\u3002\u6846\u67b6\u57fa\u4e8e Vue.js \u6838\u5fc3\uff0cmpvue \u4fee\u6539\u4e86 Vue.js \u7684 runtime \u548c compiler \u5b9e\u73b0\uff0c\u4f7f\u5176\u53ef\u4ee5\u8fd0\u884c\u5728\u5c0f\u7a0b\u5e8f\u73af\u5883\u4e2d\uff0c\u4ece\u800c\u4e3a\u5c0f\u7a0b\u5e8f\u5f00\u53d1\u5f15\u5165\u4e86\u6574\u5957 Vue.js \u5f00\u53d1\u4f53\u9a8c\u3002mp \u5373 mini program \u7684\u7f29\u5199\u3002\n<\/p><\/blockquote>\n<h2><span style=\"font-size: 14px\">\u4e8c\u3001mpvue\u5feb\u901f\u5165\u95e8<\/span><\/h2>\n<p>\u2460 \u901a\u8fc7\u811a\u624b\u67b6\u5f15\u5165mpvue\u6a21\u677f<\/p>\n<blockquote><p>\n  vue 3.0\u5df2\u7ecf<br \/>\n <strong>\u4e0d\u652f\u6301vue init\u547d\u4ee4<\/strong>\u4e86\uff0c\u6240\u4ee5\u9700\u8981\u5355\u72ec\u5b89\u88c5<br \/>\n <strong>@vue\/cli-init<\/strong>\uff0c\u5b89\u88c5\u597d\u4e4b\u540e\uff0c\u5c31\u53ef\u4ee5\u6309\u4ee5\u4e0b\u64cd\u4f5c\u6b65\u9aa4\u5f15\u5165mpvue\u6a21\u677f\u4e86\n<\/p><\/blockquote>\n<pre>npm install -g @vue\/cli-init\n\nvue init mpvue\/mpvue-quickstart my-project\n\ncd my-project\n\nnpm install\n\nnpm run dev<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<blockquote><p>\n  npm run dev\u547d\u4ee4\u4f1a\u5728\u9879\u76ee\u6839\u76ee\u5f55\u4e0b\u751f\u6210\u4e00\u4e2adist\u76ee\u5f55\uff0c\u5176\u5c31\u662f<br \/>\n <strong>\u5c06vue\u7684\u9879\u76ee\u8f6c\u6362\u4e3a\u5fae\u4fe1\u5c0f\u7a0b\u5e8f\u9879\u76ee<\/strong>\n<\/p><\/blockquote>\n<p>\u2461 \u642d\u5efa\u5c0f\u7a0b\u5e8f\u7684\u5f00\u53d1\u73af\u5883<\/p>\n<blockquote><p>\n  \u5fae\u4fe1\u63d0\u4f9b\u4e86\u4e00\u4e2a\u4e13\u95e8<br \/>\n <strong>\u5fae\u4fe1\u5f00\u53d1\u8005\u5de5\u5177<\/strong>\u7528\u4e8e\u5f00\u53d1\u5c0f\u7a0b\u5e8f\uff0c\u9700\u8981\u4e0b\u8f7d\u5b89\u88c5\u5fae\u4fe1\u5f00\u53d1\u8005\u5de5\u5177\uff0c\u540c\u65f6\u8fd8\u9700\u8981\u7533\u8bf7\u4e00\u4e2a\u5c0f\u7a0b\u5e8fID\uff0c\u5373<br \/>\n <strong>AppID<\/strong>\uff0c\u56e0\u4e3a<br \/>\n <strong>\u901a\u8fc7\u5fae\u4fe1\u5f00\u53d1\u8005\u5de5\u5177\u521b\u5efa\u5c0f\u7a0b\u5e8f\u9879\u76ee\u9700\u8981\u586b\u5165AppID<\/strong>\uff0c\u53ef\u4ee5\u5728\u5fae\u4fe1\u516c\u4f17\u5e73\u53f0\u7533\u8bf7\u5f97\u5230\u3002\n<\/p><\/blockquote>\n<p>\u2462 \u8c03\u8bd5\u9879\u76ee<\/p>\n<blockquote><p>\n  \u901a\u8fc7\u5fae\u4fe1\u5f00\u53d1\u8005\u5de5\u5177\u542f\u52a8\u5fae\u4fe1\u5c0f\u7a0b\u5e8f\u9879\u76ee\uff0c\u9009\u62e9\u7684\u9879\u76ee\u76ee\u5f55<br \/>\n <strong>\u662fmpvue\u9879\u76ee\u7684\u6839\u76ee\u5f55\uff0c\u800c\u4e0d\u662f\u751f\u6210\u7684dist\u76ee\u5f55<\/strong>\uff0c\u7531\u4e8e<br \/>\n <strong>\u5fae\u4fe1\u5f00\u53d1\u8005\u5de5\u5177\u4e0d\u652f\u6301.vue\u6587\u4ef6\u7684\u67e5\u770b<\/strong>\uff0c\u6240\u4ee5\u6211\u4eec\u8fd8\u662f\u8981\u7528\u81ea\u5df1\u7684\u5f00\u53d1\u5de5\u5177\u8c03\u8bd5\u6e90\u7801\u3002\n<\/p><\/blockquote>\n<h2><span style=\"font-size: 14px\">\u4e09\u3001mpvue\u7684\u4e00\u4e9b\u4f7f\u7528\u7ec6\u8282<\/span><\/h2>\n<p>\u2460 mpvue\u7684src\u76ee\u5f55\u4e0b\u548cvue\u4e00\u6837\uff0c<span style=\"font-size: 14px\"><strong>\u4e5f\u6709\u4e00\u4e2aApp.vue\u6839\u7ec4\u4ef6<\/strong>\uff0c<strong>App.vue\u6839\u7ec4\u4ef6\u53ea\u662f\u4e00\u4e2a\u7ed3\u6784<\/strong>\uff0c<strong>\u65e0\u5177\u4f53\u5185\u5bb9<\/strong>\uff0c\u6839\u7ec4\u4ef6\u6709\u5bf9\u5e94\u7684<strong>main.js<\/strong>\u6587\u4ef6\u7528\u4e8e\u6e32\u67d3App.vue\u6839\u7ec4\u4ef6\uff0c\u5373<strong>\u5f15\u5165App.vue\u5e76\u4f5c\u4e3aVue\u6784\u9020\u51fd\u6570\u521b\u5efaVue\u5b9e\u4f8b\uff0c\u7136\u540emount<\/strong>\uff0c\u8fd8\u6709\u4e00\u4e2a<strong>app.json<\/strong>\u6587\u4ef6\uff0c\u5373<strong>\u9875\u9762\u5168\u5c40\u914d\u7f6e\u6587\u4ef6<\/strong>\uff0c\u7528\u4e8e<strong>\u9875\u9762\u7684\u6ce8\u518c<\/strong>\u3001<strong>tabBar\u7684\u6ce8\u518c<\/strong>\u3001<strong>\u5168\u5c40window\u6837\u5f0f\u8bbe\u7f6e<\/strong>\uff0c\u5982:<\/span><\/p>\n<p>\/\/ App.vue<\/p>\n<p><span>\u7acb\u5373\u5b66\u4e60<\/span>\u201c\u201d\uff1b<\/p>\n<pre>&lt;script&gt;\n\nexport default {\n \n}\n&lt;\/script&gt;\n\n&lt;style&gt;\npage {\n  width: 100%;\n  height: 100%;\n  background-color: #f7f7f7;\n}\n&lt;\/style&gt;<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\/\/ main.js<\/p>\n<pre>import Vue from 'vue'\nimport App from '.\/App'\nVue.config.productionTip = false\nApp.mpType = 'app'\n\nconst app = new Vue(App)\napp.$mount()<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\/\/ app.json<\/p>\n<pre>{\n  \"pages\": [\n    \"pages\/index\/main\"\n  ],\n  \"tabBar\": {\n    ......\n  },\n  \"window\": {\n    \"backgroundColor\":\"#00BFFF\",\n    \"backgroundTextStyle\": \"light\",\n    \"navigationBarBackgroundColor\": \"#fff\",\n    \"navigationBarTitleText\": \"\u6d4b\u8bd5\",\n    \"navigationBarTextStyle\": \"black\"\n  }\n}<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u2461 mpvue\u4e2d\u5b9a\u4e49\u7684\u9875\u9762\u90fd\u653e\u5728src\u76ee\u5f55\u4e0b\u7684<span style=\"font-size: 14px\"><strong>pages\u76ee\u5f55<\/strong>\u91cc\u9762\uff0c<strong>\u4e00\u4e2a\u9875\u9762\u5bf9\u5e94\u4e00\u4e2a\u6587\u4ef6\u5939<\/strong>\uff0c\u6bcf\u4e2a\u9875\u9762\u6587\u4ef6\u5939\u5185\u9700\u8981\u6709\u4e00\u4e2a<strong>.vue\u6587\u4ef6<\/strong>\u548c<strong>main.js\u6587\u4ef6<\/strong>\uff0cmain.js\u4e3b\u8981\u505a\u7684\u5c31\u662f\uff0c<strong>\u5f15\u5165\u5f53\u524d\u9875\u9762\u5bf9\u5e94\u7684.vue\uff0c\u7136\u540e\u4f5c\u4e3aVue\u6784\u9020\u51fd\u6570\u7684\u53c2\u6570\u521b\u5efaVue\u5b9e\u4f8b\u5e76mount<\/strong>\uff0c\u5e76\u4e14<strong>main.js\u7684\u540d\u79f0\u4e0d\u80fd\u6539\u53d8<\/strong>\uff0c<strong>\u53ea\u80fd\u662fmain<\/strong>.<\/span><\/p>\n<p>\/\/ main.js<\/p>\n<pre>import Vue from 'vue'\nimport App from '.\/index'\n\n\/\/ add this to handle exception\nVue.config.errorHandler = function (err) {\n  if (console &amp;&amp; console.error) {\n    console.error(err)\n  }\n}\n\nconst app = new Vue(App)\napp.$mount()<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<blockquote><p>\n  \u5728mpvue\u4e2d\uff0c\u4e00\u4e2a\u9875\u9762\u4e2d\u7684.vue\u6587\u4ef6\u7684\u540d\u5b57\u867d\u7136\u53ef\u4ee5\u4efb\u610f\uff0c\u4f46\u662f<br \/>\n <strong>.js\u548c.json\u6587\u4ef6\u540d\u5b57\u662f\u56fa\u5b9a\u4e3amain\u7684<\/strong>\uff0c\u901a\u5e38\u6211\u4eec.vue\u6587\u4ef6\u4e5f\u662f\u56fa\u5b9a\u4f7f\u7528index.vue\uff0c\u6240\u6709<br \/>\n <strong>\u4e00\u4e2a\u9875\u9762\u4e2d\u901a\u5e38\u56fa\u5b9a\u5305\u542bindex.vue\u3001main.js\u3001main.json<\/strong>\uff0c<br \/>\n <strong>\u901a\u8fc7\u5916\u5c42\u7684\u6587\u4ef6\u5939\u6765\u533a\u5206\u4e0d\u540c\u7684\u9875\u9762<\/strong>\uff0c\u800c\u539f\u751f\u5c0f\u7a0b\u5e8f\u4e2d\uff0c\u4e5f\u662f\u901a\u8fc7\u5916\u5c42\u6587\u4ef6\u5939\u6765\u533a\u5206\u4e0d\u540c\u7684\u9875\u9762\uff0c\u4f46\u662f<br \/>\n <strong>\u6587\u4ef6\u5939\u4e2d\u7684\u56db\u4e2a\u9875\u9762\u7684\u540d\u79f0\u53ef\u4ee5\u548c\u5916\u5c42\u6587\u4ef6\u5939\u76f8\u540c\uff0c\u4e5f\u53ef\u4ee5\u4e0d\u540c\uff0c\u4f46\u56db\u4e2a\u6587\u4ef6\u5fc5\u987b\u7edf\u4e00<\/strong>\u3002\n<\/p><\/blockquote>\n<p>\u2462 <span style=\"font-size: 14px\"><strong>\u6bcf\u6b21\u65b0\u589e\u4e86\u9875\u9762\uff0c\u9700\u8981\u91cd\u65b0\u542f\u52a8\u9879\u76ee<\/strong>\uff0c\u5373\u91cd\u65b0\u6267\u884cnpm run dev.<\/span><\/p>\n<h2><span style=\"font-size: 14px\">\u56db\u3001\u5fae\u4fe1\u5c0f\u7a0b\u5e8f\u57fa\u7840\u4e0e\u5e38\u7528API<\/span><\/h2>\n<p><span style=\"font-size: 14px\">\u2460 <strong>\u70b9\u51fb\u6309\u94ae\u63d0\u793a\u7528\u6237\u662f\u5426\u6388\u6743\u5e76\u83b7\u53d6\u7528\u6237\u4fe1\u606f<\/strong><\/span><\/p>\n<blockquote><p>\n  \u5fae\u4fe1\u5c0f\u7a0b\u5e8f\u7ed9\u6211\u4eec\u7684\u6309\u94ae<br \/>\n <strong><\/strong>\u63d0\u4f9b\u4e86\u4e00\u4e9b<br \/>\n <strong>\u5fae\u4fe1\u5f00\u53d1\u7684\u80fd\u529b<\/strong>\uff0c\u5176\u901a\u8fc7\u7ed9 \u6807\u7b7e\u6dfb\u52a0\u4e00\u4e2a<br \/>\n <strong>open-type<\/strong>\u5c5e\u6027\uff0c\u8868\u793a<br \/>\n <strong>\u8981\u7ed9\u6309\u94ae\u5f00\u653e\u7684\u80fd\u529b\u7c7b\u578b<\/strong>\uff0c\u6bd4\u5982<br \/>\n <strong>getUserInfo<\/strong>\uff0c\u5373\u70b9\u51fb\u6309\u94ae\u83b7\u53d6\u7528\u6237\u4fe1\u606f\u7684\u80fd\u529b\uff0c\u6211\u4eec\u9700\u8981\u5728 \u4e0a\u901a\u8fc7\u76d1\u542c<br \/>\n <strong>getuserinfo<\/strong>\u4e8b\u4ef6\uff0cmpvue\u5728\u5c0f\u7a0b\u5e8f\u7684\u57fa\u7840\u4e0a\u8fdb\u884c\u4e86\u5c01\u88c5\uff0c\u9700\u8981\u901a\u8fc7<br \/>\n <strong>e.mp.detail.userInfo<\/strong>\u624d\u80fd\u83b7\u53d6\u5230\u7528\u6237\u4fe1\u606f\uff0c\n<\/p><\/blockquote>\n<pre>&lt;button open-type=\"getUserInfo\" @getuserinfo=\"getUserInfo\"&gt;\u70b9\u51fb\u5f00\u59cb&lt;\/button&gt;\n&lt;script&gt;\nexport default {\n    getUserInfo(e) {\n      console.log(e.mp.detail.userInfo); \/\/ \u83b7\u53d6\u7528\u6237\u4fe1\u606f\n    }\n}\n&lt;\/script&gt;<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u2461 <strong>wx\u5168\u5c40\u5bf9\u8c61<\/strong><br \/>\u5c31\u50cf\u7f51\u9875\u8fd0\u884c\u5728\u6d4f\u89c8\u5668\u73af\u5883\u4e00\u6837\uff0c\u6d4f\u89c8\u5668\u73af\u5883\u4f1a\u63d0\u4f9b\u4e00\u4e2a\u5168\u5c40\u7684window\u5bf9\u8c61\uff0c\u540c\u6837\u5c0f\u7a0b\u5e8f\u662f\u8fd0\u884c\u5728\u5c0f\u7a0b\u5e8f\u73af\u5883\u4e2d\uff0c<strong>\u5c0f\u7a0b\u5e8f\u73af\u5883\u4e5f\u4f1a\u63d0\u4f9b\u4e00\u4e2a\u5168\u5c40\u7684wx\u5bf9\u8c61<\/strong>\uff0cwx\u4f1a\u63d0\u4f9b\u5f88\u591aapi\uff0c\u6bd4\u5982\u8bbf\u95ee\u7f51\u7edc(<strong>wx.request({})<\/strong>)\u3001\u9875\u9762\u8df3\u8f6c(<strong>wx.redirectTo({})<\/strong>)\u3001\u663e\u793aloading(<strong>wx.showLoading({})<\/strong>)\u3001\u663e\u793a\u63d0\u793a(<strong>wx.showToast({})<\/strong>)\u7b49<\/p>\n<p>\u2462 <span style=\"font-size: 14px\"><strong>\u5fae\u4fe1\u5c0f\u7a0b\u5e8f\u4e2d\u53d1\u8d77\u7f51\u7edc\u8bf7\u6c42<\/strong><br \/>\u5728\u5c0f\u7a0b\u5e8f\u73af\u5883\u4e2d\u4e0d\u80fd\u50cf\u6d4f\u89c8\u5668\u73af\u5883\u4e00\u4e2a\u76f4\u63a5\u63d0\u4f9bajax\uff0c\u800c\u662f\u63d0\u4f9b\u4e86\u4e00\u4e2a\u5168\u5c40\u7684\u7f51\u7edc\u8bf7\u6c42api\uff0c\u5373wx.request(),\u5728\u5c0f\u7a0b\u5e8f\u73af\u5883\u4e2d\u53ea\u80fd\u4f7f\u7528wx.request()\u53d1\u8d77\u7f51\u7edc\u8bf7\u6c42\uff0c<strong>\u4e0d\u80fd\u4f7f\u7528axios<\/strong>\u7b49\u5e38\u7528\u7684\u8bf7\u6c42\u7c7b\u5e93\uff0c\u5e76\u4e14wx.request()\u5e76<strong>\u4e0d\u5b58\u5728\u8de8\u57df\u95ee\u9898<\/strong>\u3002\u4f7f\u7528wx.request()\u7684\u65f6\u5019\uff0c<strong>\u9700\u8981\u4f20\u9012\u4e00\u4e2a\u8bf7\u6c42\u53c2\u6570\u914d\u7f6e\u5bf9\u8c61<\/strong>\uff0c<strong>request()\u65b9\u6cd5\u8fd4\u56de\u7ed3\u679c\u5e76\u4e0d\u662f\u4e00\u4e2aPromise\u5bf9\u8c61<\/strong>\uff0c\u6240\u4ee5\u4e0d\u80fd\u901a\u8fc7.then()\u7684\u65b9\u5f0f\u53bb\u5904\u7406\u8bf7\u6c42\u7ed3\u679c\uff0c\u800c\u662f<strong>\u5728\u8bf7\u6c42\u914d\u7f6e\u5bf9\u8c61\u4e2d\u6dfb\u52a0\u4e86success\u3001fail\u3001complete\u7b49\u56de\u8c03\u51fd\u6570<\/strong>\uff0c\u5728\u56de\u8c03\u51fd\u6570\u4e2d\u53ef\u4ee5\u83b7\u53d6\u5230\u8bf7\u6c42\u7684\u7ed3\u679c\uff0c\u5982:<\/span><\/p>\n<pre>wx.request({\n    url: \"http:\/\/www.baidu.com\", \/\/ \u8bf7\u6c42url\u5730\u5740\u5fc5\u586b\n    data: {\n        user: \"even li\"\n    },\n    method: \"get\", \/\/ \u8bf7\u6c42\u65b9\u6cd5\n    header: {\n        \"content-type\": \"application\/json\" \/\/ \u9ed8\u8ba4\u503c\n    },\n    success(res) {\n        console.log(res.data); \/\/ \u83b7\u53d6\u54cd\u5e94\u6570\u636e\n    },\n    fail(error) {\n        console.log(error); \/\/ \u8bf7\u6c42\u5931\u8d25\n    }\n    complete(res) { \/\/ \u63a5\u53e3\u8c03\u7528\u7ed3\u675f\uff0c\u8bf7\u6c42\u6210\u529f\u6216\u5931\u8d25\u90fd\u4f1a\u6267\u884c\n        console.log(res); \/\/ \u5982\u679c\u8bf7\u6c42\u6210\u529f\u5219res\u4e3a\u54cd\u5e94\u7ed3\u679cres\uff0c\u5982\u679c\u8bf7\u6c42\u5931\u8d25\u5219res\u4e3a\u9519\u8bef\u4fe1\u606ferror\n    }\n});<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<blockquote><p>\n  \u9700\u8981\u6ce8\u610f\u7684\u662f\uff0c<br \/>\n <strong>\u8fd4\u56de\u72b6\u6001\u7801\u4e3a404\u4e5f\u7b97\u8bf7\u6c42\u6210\u529f<\/strong>\uff0c<br \/>\n <strong>\u4e00\u822c\u53ea\u6709\u7f51\u7edc\u5f02\u5e38\u7684\u65f6\u5019\u624d\u7b97\u8bf7\u6c42\u5931\u8d25<\/strong>\u3002\n<\/p><\/blockquote>\n<p>\u2463 <span style=\"font-size: 14px\"><strong>\u8df3\u8f6c\u9875\u9762\u975etabBar\u9875\u9762<\/strong><br \/>\u5982\u679c\u60f3\u8981\u8df3\u8f6c\u5230\u67d0\u4e2a\u975etabBar\u9875\u9762\uff0c\u90a3\u4e48\u53ef\u4ee5\u4f7f\u7528\u4e00\u4e2a\u5168\u5c40\u7684api\uff0c\u5373<strong>wx.redirectTo({})<\/strong>\uff0c\u5176\u4f5c\u7528\u5c31\u662f<strong>\u5173\u95ed\u5f53\u524d\u9875\u9762\uff0c\u8df3\u8f6c\u5230\u5e94\u7528\u5185\u7684\u67d0\u4e2a\u9875\u9762\u3002\u4f46\u662f\u4e0d\u5141\u8bb8\u8df3\u8f6c\u5230 tabbar \u9875\u9762<\/strong>\u3002\u9700\u8981\u4f20\u9012\u4e00\u4e2a\u914d\u7f6e\u5bf9\u8c61\uff0c\u4e3b\u8981\u5c5e\u6027\u4e3a<strong>url<\/strong>\uff0c\u5373<strong>\u8981\u8df3\u8f6c\u9875\u9762\u7684\u8def\u5f84\uff0c\u53ef\u5e26\u53c2\u6570<\/strong>\uff0c\u7136\u540e\u5c31\u662fsuccess\u3001fail\u3001complete\u4e09\u4e2a\u56de\u8c03\u51fd\u6570\uff0c\u8bf7<strong>\u5904\u7406\u8df3\u8f6c\u7ed3\u679c<\/strong>\uff0c\u5982:<\/span><\/p>\n<pre>wx.redirectTo({\n    url: \"..\/question\/main\", \/\/ \u5728\u67d0\u4e2a\u9875\u9762\u5185..\/\u76f8\u5f53\u4e8epages\/\n    success() {\n    },\n    fail() {\n    },\n    complete() {\n    }\n});<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u2464 <span style=\"font-size: 14px\"><strong>\u8df3\u8f6c\u5230tabBar\u9875\u9762<\/strong><br \/>\u5728\u5fae\u4fe1\u5c0f\u7a0b\u5e8f\u4e2d\uff0ctabBar\u9875\u9762\u662f\u9700\u8981\u7279\u6b8a\u7684\u65b9\u5f0f\u8df3\u8f6c\u7684\uff0c\u5373\u4f7f\u7528<strong>wx.switchTab({})<\/strong>\u7684\u65b9\u5f0f\uff0c\u5176<strong>\u4f1a\u8df3\u8f6c\u5230 tabBar \u9875\u9762\uff0c\u5e76\u5173\u95ed\u5176\u4ed6\u6240\u6709\u975e tabBar \u9875\u9762<\/strong>\uff0c\u5176\u7528\u6cd5\u540cwx.redirectTo({});<\/span><\/p>\n<pre>wx.switchTab({\n   url: \"..\/learn\/main\", \/\/ \u5728\u67d0\u4e2a\u9875\u9762\u5185..\/\u76f8\u5f53\u4e8epages\/\nsuccess() {\n    },\n    fail() {\n    },\n    complete() {\n    }\n});<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u2465 <span style=\"font-size: 14px\"><strong>\u9875\u9762\u914d\u7f6e\u6587\u4ef6<\/strong><br \/>\u5c0f\u7a0b\u5e8f\u7684\u9875\u9762\u914d\u7f6e\u6587\u4ef6\u5206\u4e3a<strong>\u5168\u5c40\u914d\u7f6e\u6587\u4ef6<\/strong>app.json\u4e0e\u5373<strong>\u9875\u9762\u914d\u7f6e<\/strong>main.json. \u5168\u5c40\u914d\u7f6e\u6587\u4ef6\u53ef\u914d\u7f6e\u9879\u6bd4\u8f83\u591a\uff0c\u6574\u4e2a\u914d\u7f6e\u6587\u4ef6\u5185\u5bb9\u8981\u7528\u82b1\u62ec\u53f7\u62ec\u8d77\u6765\uff0c\u4e5f\u5c31\u662f\u8bf4<strong>\u662f\u4e00\u4e2aJSON\u5bf9\u8c61<\/strong>\uff0c\u5982:<\/span><\/p>\n<ul>\n<li><span style=\"font-size: 14px\"><strong>pages<\/strong>\u5c5e\u6027\uff0c\u662f\u4e00\u4e2a<strong>\u6570\u7ec4<\/strong>\uff0c\u7528\u4e8e<strong>\u5b9a\u4e49\u5c0f\u7a0b\u5e8f\u7528\u5230\u7684\u9875\u9762<\/strong>\uff0c\u6570\u7ec4\u4e2d\u6bcf\u4e00\u9879\u5bf9\u5e94\u4e00\u4e2a\u9875\u9762\uff0c\u5373<strong>\u8def\u5f84+\u6587\u4ef6\u540d<\/strong>\u4fe1\u606f\uff0c\u4e0d\u9700\u8981\u5199\u540e\u7f00\uff0c\u5728mpvue\u4e2d\u6240\u6709\u9875\u9762\u56fa\u5b9a\u4f7f\u7528main\uff0c\u5373\u6bcf\u4e2a\u9875\u9762\u4e0b\u90fd\u4f1a\u6709\u4e00\u4e2amain.js\uff0c\u6240\u4ee5\u5728\u914d\u7f6epages\u65f6\uff0c\u901a\u5e38\u4e3a&#8221;<strong>pages\/\u9875\u9762\u540d\/main<\/strong>&#8220;\uff0c\u4f4d\u4e8e<strong>pages\u6570\u7ec4\u7b2c\u4e00\u9879<\/strong>\u8868\u793a\u5c0f\u7a0b\u5e8f\u7684\u521d\u59cb\u9875\u9762\uff0c\u5373<strong>\u5c0f\u7a0b\u5e8f\u8fd0\u884c\u65f6\u663e\u793a\u7684\u9875\u9762<\/strong>\u3002<\/span><\/li>\n<li><span style=\"font-size: 14px\"><strong>window<\/strong>\u5c5e\u6027\uff0c\u5373\u5bf9\u5c0f\u7a0b\u5e8f\u7684<strong>\u7a97\u53e3\u6837\u5f0f<\/strong>\u8fdb\u884c\u914d\u7f6e\uff0c\u5176\u5c5e\u6027\u503c\u4e3a\u4e00\u4e2a\u5bf9\u8c61\uff0c\u4e3b\u8981\u5305\u62ec<strong>backgroundColor<\/strong>(\u7a97\u53e3\u80cc\u666f\u989c\u8272\uff0c\u5373<strong>\u9875\u9762\u4e0b\u62c9\u540e\u6f0f\u51fa\u7684\u80cc\u666f\u7a97\u53e3\u989c\u8272<\/strong>)\u3001backgroundTextStyle(\u8bbe\u7f6e\u4e0b\u62c9\u80cc\u666f\u5b57\u4f53\u3001loading\u56fe\u7684\u6837\u5f0f\uff0c<strong>\u76ee\u524d\u53ea\u652f\u6301dark\u548clight<\/strong>)\u3001<strong>navigationBarBackgroundColor<\/strong>(\u5bfc\u822a\u680f\u80cc\u666f\u989c\u8272)\u3001navigationBarTextStyle(\u5bfc\u822a\u680f\u6807\u9898\u989c\u8272\uff0c<strong>\u76ee\u524d\u53ea\u652f\u6301black\u548cwhite<\/strong>)\u3001navigationBarTitleText(\u5bfc\u822a\u680f\u6807\u9898\u6587\u5b57\u5185\u5bb9)\u3001navigationStyle(<strong>\u503c\u4e3acustom\u81ea\u5b9a\u4e49\u5bfc\u822a\u680f<\/strong>)<\/span><\/li>\n<\/ul>\n<blockquote><p>\n <span style=\"font-size: 14px\">\u5fae\u4fe1\u5c0f\u7a0b\u5e8f\u8bbe\u7f6e\u989c\u8272\u7684\u65f6\u5019\uff0c<strong>\u53ea\u652f\u6301\u5341\u516d\u8fdb\u5236\u989c\u8272<\/strong>\uff0c\u4e0d\u652f\u6301RGB\u683c\u5f0f\u548c\u989c\u8272\u82f1\u6587\u3002<\/span>\n<\/p><\/blockquote>\n<ul>\n<li><span style=\"font-size: 14px\"><strong>tarBar<\/strong>\u5c5e\u6027\uff0c\u7528\u4e8e\u914d\u7f6e\u7a97\u53e3\u5e95\u90e8\u7684tabBar\uff0c\u5176\u5c5e\u6027\u503c\u4e3a\u4e00\u4e2a<strong>\u5bf9\u8c61<\/strong>\uff0c\u4e3b\u8981\u6709color(\u8bbe\u7f6etab\u672a\u6fc0\u6d3b\u72b6\u6001\u6587\u5b57\u7684\u989c\u8272)\u3001selectedColor(\u8bbe\u7f6etab\u6fc0\u6d3b\u72b6\u6001\u7684\u6587\u5b57\u989c\u8272)\u3001borderStyle(\u8bbe\u7f6etabBar\u4e0a\u8fb9\u6846\u7684\u989c\u8272\uff0c\u76ee\u524d\u53ea\u652f\u6301black\u548cwhite)\u3001backgroundColor(\u8bbe\u7f6etab\u7684\u80cc\u666f\u989c\u8272)\u3001list(\u7528\u4e8e\u914d\u7f6etab\u9879\uff0c<strong>\u6700\u591a\u53ef\u914d\u7f6e5\u9879<\/strong>)\uff0c<strong>list\u5c5e\u6027\u503c\u4e3a\u4e00\u4e2a\u6570\u7ec4<\/strong>\uff0c\u4e3b\u8981\u5305\u62ec<strong>text<\/strong>(tab\u4e0a\u663e\u793a\u7684\u6587\u5b57\u5185\u5bb9)\u3001<strong>iconPath<\/strong>(tab\u5904\u4e8e\u672a\u6fc0\u6d3b\u72b6\u6001\u65f6\u663e\u793a\u7684\u56fe\u6807\u8def\u5f84)\u3001<strong>selectedPath<\/strong>(tab\u5904\u4e8e\u6fc0\u6d3b\u72b6\u6001\u65f6\u663e\u793a\u7684\u56fe\u6807\u8def\u5f84)\u3001<strong>pagePath<\/strong>(tab\u88ab\u70b9\u51fb\u65f6\u8981\u8df3\u8f6c\u7684\u9875\u9762\u8def\u5f84\uff0c<strong>\u5176\u5c5e\u6027\u503c\u4e3apages\u4e2d\u914d\u7f6e\u7684\u8def\u5f84<\/strong>)<\/span><\/li>\n<\/ul>\n<blockquote><p>\n  \u9875\u9762\u914d\u7f6e\u914d\u7f6e\u76f8\u5bf9\u4e8e\u5168\u5c40\u4e3b\u914d\u7f6e\u6587\u4ef6\u6765\u8bf4\u8981\u7b80\u5355\u5f97\u591a\uff0c\u5728<br \/>\n <strong>\u9875\u9762\u914d\u7f6e\u6587\u4ef6\u4e2d\u53ea\u80fd\u914d\u7f6e\u7a97\u53e3\u7684\u6837\u5f0f\u5c5e\u6027<\/strong>\uff0c\u5373\u53ea\u80fd\u914d\u7f6e\u5168\u5c40\u914d\u7f6e\u6587\u4ef6\u4e2d\u7684window\u5c5e\u6027\u4e2d\u7684\u5185\u5bb9\uff0c<br \/>\n <strong>\u9875\u9762\u914d\u7f6e\u6587\u4ef6\u4e2d\u914d\u7f6e\u7684\u5185\u5bb9\u4f1a\u8986\u76d6\u6389\u5168\u5c40\u914d\u7f6e\u6587\u4ef6\u4e2dwindow\u4e2d\u76f8\u540c\u7684\u914d\u7f6e<\/strong>\uff0c\u4ee5\u51b3\u5b9a\u5f53\u524d\u9875\u9762\u7684\u7a97\u53e3\u8868\u73b0\uff0c<br \/>\n <strong>\u65e0\u9700\u4f7f\u7528window\u5c5e\u6027\uff0c\u76f4\u63a5\u5c06window\u914d\u7f6e\u653e\u5230\u82b1\u62ec\u53f7\u4e2d\u5373\u53ef<\/strong>\u3002\n<\/p><\/blockquote>\n<p>\u2466 <span style=\"font-size: 14px\"><strong>\u5c0f\u7a0b\u5e8f\u9875\u9762<\/strong>\u4e0e<strong>Vue<\/strong>\u751f\u547d\u5468\u671f<\/span><\/p>\n<blockquote><p>\n  \u5c0f\u7a0b\u5e8f\u7ed9\u9875\u9762\u63d0\u4f9b\u4e86<br \/>\n <strong>onLoad<\/strong>(\u9875\u9762\u52a0\u8f7d)\u3001<br \/>\n <strong>onShow<\/strong>(\u9875\u9762\u663e\u793a\uff0c<br \/>\n <strong>\u4f46\u8fd8\u672a\u6e32\u67d3\u5b8c\u6210<\/strong>)\u3001onReady(\u9875\u9762\u6e32\u67d3\u5b8c\u6210)\u3001<br \/>\n <strong>onHide<\/strong>(\u9875\u9762\u9690\u85cf)\u3001<br \/>\n <strong>onUnload<\/strong>(\u9875\u9762\u5378\u8f7d)\uff0c<br \/>\n <strong>mpvue\u5c06\u5c0f\u7a0b\u5e8f\u63d0\u4f9b\u7684\u9875\u9762\u751f\u547d\u5468\u671f\u548cvue\u7684\u751f\u547d\u5468\u671f\u7ed3\u5408\u5728\u4e86\u4e00\u8d77<\/strong>\uff0c\u4e5f\u5c31\u662f\u8bf4\u4f7f\u7528mpvue\u5f00\u53d1\u5c0f\u7a0b\u5e8f\uff0c\u53ef\u4ee5\u540c\u65f6\u4f7f\u7528\u5c0f\u7a0b\u5e8f\u7684\u751f\u547d\u5468\u671f\u548cvue\u7684\u751f\u547d\u5468\u671f\uff0c\u5176\u987a\u5e8f\u4e3a:<br \/>\n <strong>beforeCreate &#8211;&gt; created &#8211;&gt; onLoad &#8211;&gt; onShow &#8211;&gt; onReady &#8211;&gt; beforeMount &#8211;&gt; mounted<\/strong>\u3002\u5373<br \/>\n <strong>Vue\u9996\u5148\u5b9e\u4f8b\u5316\u7136\u540e\u9875\u9762\u5f00\u59cb\u52a0\u8f7d\u3001\u663e\u793a\u3001\u6e32\u67d3\uff0c\u9875\u9762\u6e32\u67d3\u5b8c\u6210\u540eVue\u5b9e\u4f8b\u5f00\u59cb\u6302\u8f7d<\/strong>\u3002\n<\/p><\/blockquote>\n<p>\u2467 <span style=\"font-size: 14px\"><strong>\u5bfc\u822a\u5230\u67d0\u4e2a\u9875\u9762<\/strong><br \/>\u6240\u8c13\u5bfc\u822a\u5230\u67d0\u4e2a\u9875\u9762\uff0c\u5c31\u662f\u8df3\u8f6c\u5230\u67d0\u4e2a\u9875\u9762\uff0c\u4f46\u662f\u5176\u4f1a<strong>\u4fdd\u7559\u5f53\u524d\u9875\u9762<\/strong>\uff0c\u8df3\u8f6c\u7684\u76ee\u7684\u9875\u9762<strong>\u5bfc\u822a\u680f\u5de6\u4fa7\u4e2d\u81ea\u5e26\u4e00\u4e2a\u8fd4\u56de\u6309\u94ae<\/strong>\uff0c\u70b9\u51fb\u53ef\u4ee5\u56de\u5230\u4e4b\u524d\u7684\u9875\u9762\uff0c\u4f46\u662f<strong>\u8fd9\u4e2a\u8df3\u8f6c\u7684\u76ee\u7684\u9875\u9762\u4e0d\u80fd\u662ftabbar\u4e2d\u7684\u9875\u9762<\/strong>\uff0c\u5176\u4f7f\u7528\u7684\u662fwx.navigateTo({})<\/span><\/p>\n<pre>wx.navigateTo({\n    url: \"..\/myLesson\/main\" \/\/ \u5bfc\u822a\u5230\u6211\u7684\u8bfe\u7a0b\u9875\u9762\uff0c\u76ee\u6807\u9875\u9762\u81ea\u5e26\u8fd4\u56de\u6309\u94ae\uff0c\u70b9\u51fb\u53ef\u8fd4\u56de\u4e4b\u524d\u7684\u9875\u9762\n});<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u2468 <span style=\"font-size: 14px\"><strong>\u52a8\u6001\u8bbe\u7f6e\u9875\u9762\u5bfc\u822a\u680f\u6807\u9898<\/strong><br \/>\u5f53\u6211\u4eec\u70b9\u51fb\u5217\u8868\u4e2d\u7684\u67d0\u4e2a\u5177\u4f53\u9879\u65f6\uff0c\u901a\u5e38\u9700\u8981\u5728\u5176\u5bf9\u5e94\u9875\u9762\u52a8\u6001\u663e\u793a\u51fa\u5f53\u524d\u70b9\u51fb\u9879\u7684\u5177\u4f53\u5bfc\u822a\u680f\u6807\u9898\uff0c\u5fae\u4fe1\u5c0f\u7a0b\u5e8f\u63d0\u4f9b\u4e86<strong>wx.setNavigationBarTitle({})<\/strong>\u7528\u4e8e<strong>\u52a8\u6001\u8bbe\u7f6e\u5bfc\u822a\u680f\u680f\u6807\u9898<\/strong>\uff0c\u540c\u6837\u6709success\u3001fail\u3001complete\u4e09\u4e2a\u56de\u8c03\u51fd\u6570\uff0c\u5982:<\/span><\/p>\n<pre>wx.setNavigationBarTitle({\n     title: \"\u52a8\u6001\u6807\u9898\u5185\u5bb9\",\n     success() {\n     },\n     fail() {\n     },\n     complete() {\n     }\n});<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u2469 <span style=\"font-size: 14px\"><strong>\u672c\u5730\u7f13\u5b58\u6570\u636e<\/strong><br \/>\u5fae\u4fe1\u5c0f\u7a0b\u5e8f\u63d0\u4f9b\u4e86<strong>setStorage({})<\/strong>\u65b9\u6cd5\uff0c\u53ef\u4ee5\u5c06\u6570\u636e\u5b58\u50a8\u5728\u672c\u5730\u7f13\u5b58\u4e2d\u6307\u5b9a\u7684 key \u4e2d\uff0c<strong>\u9664\u975e\u7528\u6237\u4e3b\u52a8\u5220\u9664\u6216\u56e0\u5b58\u50a8\u7a7a\u95f4\u539f\u56e0\u88ab\u7cfb\u7edf\u6e05\u7406\uff0c\u5426\u5219\u6570\u636e\u90fd\u4e00\u76f4\u53ef\u7528<\/strong>\u3002\u5355\u4e2a key \u5141\u8bb8\u5b58\u50a8\u7684\u6700\u5927\u6570\u636e\u957f\u5ea6\u4e3a 1MB\uff0c\u6240\u6709\u6570\u636e\u5b58\u50a8\u4e0a\u9650\u4e3a 10MB\u3002\u5982:<\/span><\/p>\n<pre>wx.setStorage({\n    key:\"key\",\n    data:\"value\"\n});<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u540c\u6837\uff0c\u5fae\u4fe1\u5c0f\u7a0b\u5e8f\u4e5f\u63d0\u4f9b\u4e86getStorage({})\u65b9\u6cd5\uff0c\u7528\u4e8e\u83b7\u53d6\u5bf9\u5e94key\u4e2d\u5b58\u50a8\u7684\u6570\u636e\uff0c\u5176\u8fd8\u6709success\u3001fail\u3001complete\u4e09\u4e2a\u56de\u8c03\u51fd\u6570\uff0c\u5982:<\/p>\n<pre>wx.getStorage({\n    key: \"key\",\n    success (res) { \/\/ \u6210\u529f\u83b7\u53d6\u5230\u5bf9\u5e94key\u4e2d\u7684\u6570\u636e\n    },\n    fail() { \/\/ \u672a\u6210\u529f\u83b7\u53d6\u5230\u5bf9\u5e94key\u4e2d\u7684\u6570\u636e\n    },\n    complete() { \/\/ \u83b7\u53d6\u5bf9\u5e94key\u6570\u636e\u7ed3\u675f\uff0c\u4e0d\u7ba1\u6210\u529f\u8fd8\u662f\u5931\u8d25\u90fd\u4f1a\u6267\u884c\n    }\n});<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<blockquote><p>\n  getStorage()\u548csetStorage()\u65b9\u6cd5\u672c\u8eab\u662f<br \/>\n <strong>\u5f02\u6b65\u7684<\/strong>\uff0c\u4f46\u662f\u5fae\u4fe1\u5c0f\u7a0b\u5e8f\u63d0\u4f9b\u4e86\u5bf9\u5e94\u7684\u540c\u6b65\u65b9\u6cd5\uff0c\u5373<br \/>\n <strong>getStorageSync(&#8220;key&#8221;)<\/strong>\u548c<br \/>\n <strong>setStorageSync(&#8220;key&#8221;, &#8220;value&#8221;)<\/strong>;\n<\/p><\/blockquote>\n<p>\u246a <span style=\"font-size: 14px\"><strong>\u8f6e\u64ad\u56fe\u7ec4\u4ef6<\/strong><br \/>\u5fae\u4fe1\u5c0f\u7a0b\u5e8f\u63d0\u4f9b\u4e86\u4e00\u4e2a<strong> <\/strong>\u8f6e\u64ad\u56fe\u7ec4\u4ef6\uff0c\u5176\u4e2d\u53ea\u53ef\u653e\u7f6e<strong>swiper-item\u7ec4\u4ef6<\/strong>\uff0cswiper\u6709\u4e00\u4e9b\u5e38\u7528\u7684\u5c5e\u6027\uff0c\u5982:<\/span><\/p>\n<ul>\n<li><span style=\"font-size: 14px\">indicator-dots: \u662f\u5426\u663e\u793a\u9762\u677f\u6307\u793a\u70b9;<\/span><\/li>\n<li><span style=\"font-size: 14px\">autoplay: \u662f\u5426\u81ea\u52a8\u5207\u6362;<\/span><\/li>\n<li><span style=\"font-size: 14px\">interval: \u8bbe\u7f6e\u81ea\u52a8\u5207\u6362\u65f6\u95f4\u95f4\u9694;<\/span><\/li>\n<li><span style=\"font-size: 14px\">duration: \u6ed1\u52a8\u52a8\u753b\u65f6\u957f;<\/span><\/li>\n<li><span style=\"font-size: 14px\">circular: \u662f\u5426\u5faa\u73af\u64ad\u653e;<\/span><\/li>\n<li><span style=\"font-size: 14px\">indicator-active-color: \u8bbe\u7f6e\u5f53\u524d\u9009\u4e2d\u7684\u6307\u793a\u70b9\u989c\u8272;<\/span><\/li>\n<\/ul>\n<pre>&lt;swiper :indicator-dots=\"indicatorDots\" \n        :autoplay=\"autoPlay\" \n        :interval=\"interval\" \n        :duration=\"duration\" \n        :circular=\"circular\" \n        indicator-active-color=\"rgba(255,255,255, 0.6)\"&gt;\n        &lt;block v-for=\"(item, index) in imgUrls\" :key=\"index\"&gt;\n            &lt;swiper-item&gt;\n                &lt;img  :src=\"item\" class=\"slide-item\"\/ alt=\"\u7528mpvue\u5f00\u53d1\u5fae\u4fe1\u5c0f\u7a0b\u5e8f\u57fa\u7840\u77e5\u8bc6\" &gt;\n            &lt;\/swiper-item&gt;\n        &lt;\/block&gt;\n&lt;\/swiper&gt;<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<blockquote><p>\n  \u5f53\u7136\uff0c \u7ec4\u4ef6\u4e0d\u4ec5\u4ec5\u80fd\u5b9e\u73b0\u56fe\u7247\u7684\u8f6e\u64ad\uff0c\u8fd8\u53ef\u4ee5\u5b9e\u73b0\u5176\u4ed6\u8f6e\u64ad\uff0c\u6bd4\u5982<br \/>\n <strong>\u5217\u8868\u5185\u5bb9\u7684\u8f6e\u64ad(\u5bfc\u822a\u548c\u5185\u5bb9\u7684\u8054\u52a8)<\/strong>\uff0c\u6211\u4eec\u4e0d\u7ed9\u5176\u6dfb\u52a0indicator-dots\u3001autoplay\u3001interval\u3001duration\u3001circular\u7b49\u5c5e\u6027\uff0c\u800c\u662f<br \/>\n <strong>\u901a\u8fc7\u624b\u8fdb\u884c\u6ed1\u52a8<\/strong>\uff0cswiper\u7ec4\u4ef6\u8fd8\u6709\u4e00\u4e2a<br \/>\n <strong>current<\/strong>\u5c5e\u6027\uff0c<br \/>\n <strong>\u5c5e\u6027\u503c\u4e3a\u6ed1\u52a8\u5757\u7684\u7d22\u5f15\u503c<\/strong>\uff0c\u7528\u4e8e\u663e\u793a\u5bf9\u5e94\u7684\u6ed1\u52a8item\uff0c\u4ece\u800c\u5b9e\u73b0\u5bfc\u822a\u548c\u5185\u5bb9\u7684\u8054\u52a8\uff0c\u5373<br \/>\n <strong>\u70b9\u51fb\u5bfc\u822a\uff0c\u81ea\u52a8\u5207\u6362\u5230\u5bf9\u5e94\u5185\u5bb9<\/strong>\u3002swiper\u7ec4\u4ef6\u4e5f\u63d0\u4f9b\u4e86change\u4e8b\u4ef6\uff0c\u5f53\u6211\u4eec\u624b\u52a8\u6ed1\u52a8\u6ed1\u52a8item\u7684\u65f6\u5019\uff0c\u5c31\u4f1a\u89e6\u53d1change\u4e8b\u4ef6\uff0c\u53ef\u4ee5\u5728\u4e8b\u4ef6\u5bf9\u8c61\u4e2d\u62ff\u5230\u5bf9\u5e94\u6ed1\u5757\u7684\u7d22\u5f15\uff0c\u4ece\u800c\u66f4\u65b0\u5bfc\u822a\u4f4d\u7f6e\uff0c\u5b9e\u73b0<br \/>\n <strong>\u6ed1\u52a8\u5185\u5bb9\uff0c\u81ea\u52a8\u9ad8\u4eae\u5bfc\u822a\u4f4d\u7f6e<\/strong>\u3002\n<\/p><\/blockquote>\n<p>\u246b <span style=\"font-size: 14px\"><strong>\u53ef\u6eda\u52a8\u533a\u57df\u7ec4\u4ef6<\/strong><br \/>\u5fae\u4fe1\u63d0\u4f9b\u4e86\u4e00\u4e2a<strong> <\/strong>\u53ef\u6eda\u52a8\u533a\u57df\u7ec4\u4ef6\uff0c\u7528\u4e8e\u8bbe\u7f6e\u8be5\u533a\u57df\u4e2d\u7684\u5185\u5bb9\u662f\u53ef\u4ee5\u6eda\u52a8\u7684\uff0c\u901a\u5e38\u7528\u4e8e\u5b9e\u73b0<strong>\u53ef\u6eda\u52a8\u7684\u5bfc\u822a\u6807\u7b7e\u680f<\/strong>\uff0c\u5176\u5e38\u7528\u5c5e\u6027\u4e3a:<\/span><\/p>\n<ul>\n<li><span style=\"font-size: 14px\">scroll-x: \u662f\u5426\u5141\u8bb8\u6a2a\u5411\u6eda\u52a8;<\/span><\/li>\n<li><span style=\"font-size: 14px\">scroll-y: \u662f\u5426\u5141\u8bb8\u7eb5\u5411\u6eda\u52a8;<\/span><\/li>\n<li><span style=\"font-size: 14px\">scroll-into-view: \u5c5e\u6027\u503c\u4e3a\u5bf9\u5e94\u6eda\u52a8item\u7684id\uff0c\u8868\u793a\u81ea\u52a8\u6eda\u52a8\u5230\u5bf9\u5e94id\u5143\u7d20\u4f4d\u7f6e;<\/span><\/li>\n<li><span style=\"font-size: 14px\">scroll-with-animation: \u5728\u8bbe\u7f6e\u6eda\u52a8\u6761\u4f4d\u7f6e\u65f6\u4f7f\u7528\u52a8\u753b\u8fc7\u6e21;<\/span><\/li>\n<\/ul>\n<blockquote><p>\n  \u8981\u5b9e\u73b0\u70b9\u51fb\u67d0\u4e2a\u6eda\u52a8item\u540e\uff0c\u81ea\u52a8\u6eda\u52a8\u5230\u5bf9\u5e94\u6eda\u52a8item\u4f4d\u7f6e\uff0c\u90a3\u4e48\u9700\u8981\u7ed9\u6bcf\u4e2a\u6eda\u52a8item\u6dfb\u52a0\u4e00\u4e2aid\uff0c\u7136\u540e\u52a8\u6001\u6539\u53d8scroll-into-view\u7684\u503c\u4e3a\u5bf9\u5e94\u7684\u6eda\u52a8item\u7684id\u5373\u53ef\u3002\n<\/p><\/blockquote>\n<pre>&lt;scroll-view&gt;\n&nbsp;&nbsp;&nbsp;&nbsp;&lt;span&gt;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{{item.name}}\n&nbsp;&nbsp;&nbsp;&nbsp;&lt;\/span&gt;\n&lt;\/scroll-view&gt;<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u63a8\u8350\u6559\u7a0b\uff1a\u300a\u300b<\/p>\n<p>\u4ee5\u4e0a\u5c31\u662f\u7528mpvue\u5f00\u53d1\u5fae\u4fe1\u5c0f\u7a0b\u5e8f\u57fa\u7840\u77e5\u8bc6\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u8bf7\u5173\u6ce8\u7c73\u4e91\u5176\u5b83\u76f8\u5173\u6587\u7ae0\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4e00\u3001mpvue\u7b80\u4ecb mpvue \u662f\u4e00\u4e2a\u4f7f\u7528 Vue.js \u5f00\u53d1\u5c0f\u7a0b\u5e8f\u7684\u524d\u7aef\u6846\u67b6\u3002\u6846\u67b6\u57fa\u4e8e Vue.js \u6838\u5fc3\uff0cmpvue \u4fee\u6539\u4e86 Vue.js \u7684 runtime \u548c compiler \u5b9e\u73b0\uff0c\u4f7f\u5176\u53ef\u4ee5\u8fd0\u884c\u5728\u5c0f\u7a0b\u5e8f\u73af\u5883\u4e2d\uff0c\u4ece\u800c\u4e3a\u5c0f\u7a0b\u5e8f\u5f00\u53d1\u5f15\u5165\u4e86\u6574\u5957 Vue.js \u5f00\u53d1\u4f53\u9a8c\u3002mp \u5373 mini program \u7684\u7f29\u5199\u3002 \u4e8c\u3001mpvue\u5feb\u901f\u5165\u95e8 \u2460 \u901a\u8fc7\u811a\u624b\u67b6\u5f15\u5165mpvue\u6a21\u677f vue 3.0\u5df2\u7ecf \u4e0d\u652f\u6301vue init\u547d\u4ee4\u4e86\uff0c\u6240\u4ee5\u9700\u8981\u5355\u72ec\u5b89\u88c5 @vue\/cli-init\uff0c\u5b89\u88c5\u597d\u4e4b\u540e\uff0c\u5c31\u53ef\u4ee5\u6309\u4ee5\u4e0b\u64cd\u4f5c\u6b65\u9aa4\u5f15\u5165mpvue\u6a21\u677f\u4e86 npm install -g @vue\/cli-init vue init mpvue\/mpvue-quickstart my-project cd my-project npm install npm run dev \u767b\u5f55\u540e\u590d\u5236 npm run dev\u547d\u4ee4\u4f1a\u5728\u9879\u76ee\u6839\u76ee\u5f55\u4e0b\u751f\u6210\u4e00\u4e2adist\u76ee\u5f55\uff0c\u5176\u5c31\u662f \u5c06vue\u7684\u9879\u76ee\u8f6c\u6362\u4e3a\u5fae\u4fe1\u5c0f\u7a0b\u5e8f\u9879\u76ee \u2461 \u642d\u5efa\u5c0f\u7a0b\u5e8f\u7684\u5f00\u53d1\u73af\u5883 \u5fae\u4fe1\u63d0\u4f9b\u4e86\u4e00\u4e2a\u4e13\u95e8 \u5fae\u4fe1\u5f00\u53d1\u8005\u5de5\u5177\u7528\u4e8e\u5f00\u53d1\u5c0f\u7a0b\u5e8f\uff0c\u9700\u8981\u4e0b\u8f7d\u5b89\u88c5\u5fae\u4fe1\u5f00\u53d1\u8005\u5de5\u5177\uff0c\u540c\u65f6\u8fd8\u9700\u8981\u7533\u8bf7\u4e00\u4e2a\u5c0f\u7a0b\u5e8fID\uff0c\u5373 AppID\uff0c\u56e0\u4e3a \u901a\u8fc7\u5fae\u4fe1\u5f00\u53d1\u8005\u5de5\u5177\u521b\u5efa\u5c0f\u7a0b\u5e8f\u9879\u76ee\u9700\u8981\u586b\u5165AppID\uff0c\u53ef\u4ee5\u5728\u5fae\u4fe1\u516c\u4f17\u5e73\u53f0\u7533\u8bf7\u5f97\u5230\u3002 \u2462 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[19],"tags":[],"class_list":["post-33393","post","type-post","status-publish","format-standard","hentry","category-19"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/33393","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/comments?post=33393"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/33393\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=33393"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=33393"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=33393"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}