{"id":2576,"date":"2018-03-11T18:24:47","date_gmt":"2018-03-11T10:24:47","guid":{"rendered":"http:\/\/www.xttblog.com\/?p=2576"},"modified":"2018-03-11T18:24:47","modified_gmt":"2018-03-11T10:24:47","slug":"%e7%be%8e%e5%9b%a2-mpvue-%e6%95%99%e7%a8%8b","status":"publish","type":"post","link":"https:\/\/www.xttblog.com\/?p=2576","title":{"rendered":"\u7f8e\u56e2 mpvue \u6559\u7a0b"},"content":{"rendered":"<p>\n\tmpvue \u662f\u7f8e\u56e2\u5f00\u6e90\u7684\u4e00\u6b3e\u57fa\u4e8e Vue.js \u7684\u5c0f\u7a0b\u5e8f\u5f00\u53d1\u6846\u67b6\uff0c\u4ece\u5e95\u5c42\u652f\u6301 Vue.js \u8bed\u6cd5\u548c\u6784\u5efa\u5de5\u5177\u4f53\u7cfb\u3002\u672c\u6587\u5c06\u4ecb\u7ecd\u4f7f\u7528&nbsp;mpvue \u5982\u4f55\u8fdb\u884c\u5fae\u4fe1\u5c0f\u7a0b\u5e8f\u5f00\u53d1\u3002\n<\/p>\n<p>\n\t\u5b98\u7f51\u5730\u5740\u4e3a\uff1a<a href=\"http:\/\/mpvue.com\" name=\"mpvue\" target=\"_blank\" title=\"mpvue\">http:\/\/mpvue.com<\/a>\u3002\n<\/p>\n<p>\n\tmpvue \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\u3002\n<\/p>\n<p>\n\t\u76ee\u524d\u7f8e\u56e2\u65d7\u4e0b\u7684\u5c0f\u7a0b\u5e8f\uff1a\u7f8e\u56e2\u6c7d\u8f66\u7968 \u548c \u7f8e\u56e2\u5145\u7535\u3002\u90fd\u662f\u91c7\u7528\u6b64\u6846\u67b6\u8fdb\u884c\u7684\u5f00\u53d1\u3002\n<\/p>\n<p>\n\tmpvue \u662f\u6709 mp \u548c vue \u7ec4\u5408\u800c\u6765\u3002mp\uff1amini program \u7684\u7f29\u5199\uff0cmpvue\uff1aVue.js in mini program\u3002\n<\/p>\n<h2>\n\tmpvue \u7684\u4e3b\u8981\u7279\u6027<br \/>\n<\/h2>\n<p>\n\t\u4f7f\u7528&nbsp;<code>mpvue<\/code>&nbsp;\u5f00\u53d1\u5c0f\u7a0b\u5e8f\uff0c\u4f60\u5c06\u5728\u5c0f\u7a0b\u5e8f\u6280\u672f\u4f53\u7cfb\u7684\u57fa\u7840\u4e0a\u83b7\u53d6\u5230\u8fd9\u6837\u4e00\u4e9b\u80fd\u529b\uff1a\n<\/p>\n<ul>\n<li>\n\t\t\u5f7b\u5e95\u7684\u7ec4\u4ef6\u5316\u5f00\u53d1\u80fd\u529b\uff1a\u63d0\u9ad8\u4ee3\u7801\u590d\u7528\u6027\n\t<\/li>\n<li>\n\t\t\u5b8c\u6574\u7684&nbsp;<code>Vue.js<\/code>&nbsp;\u5f00\u53d1\u4f53\u9a8c\n\t<\/li>\n<li>\n\t\t\u65b9\u4fbf\u7684&nbsp;<code>Vuex<\/code>&nbsp;\u6570\u636e\u7ba1\u7406\u65b9\u6848\uff1a\u65b9\u4fbf\u6784\u5efa\u590d\u6742\u5e94\u7528\n\t<\/li>\n<li>\n\t\t\u5feb\u6377\u7684&nbsp;<code>webpack<\/code>&nbsp;\u6784\u5efa\u673a\u5236\uff1a\u81ea\u5b9a\u4e49\u6784\u5efa\u7b56\u7565\u3001\u5f00\u53d1\u9636\u6bb5 hotReload\n\t<\/li>\n<li>\n\t\t\u652f\u6301\u4f7f\u7528 npm \u5916\u90e8\u4f9d\u8d56\n\t<\/li>\n<li>\n\t\t\u4f7f\u7528&nbsp;<code>Vue.js<\/code>&nbsp;\u547d\u4ee4\u884c\u5de5\u5177 vue-cli \u5feb\u901f\u521d\u59cb\u5316\u9879\u76ee\n\t<\/li>\n<li>\n\t\tH5 \u4ee3\u7801\u8f6c\u6362\u7f16\u8bd1\u6210\u5c0f\u7a0b\u5e8f\u76ee\u6807\u4ee3\u7801\u7684\u80fd\u529b\n\t<\/li>\n<\/ul>\n<p>\n\t<code>mpvue<\/code>&nbsp;\u4f5c\u4e3a\u5c0f\u7a0b\u5e8f\u7248\u672c\u7684&nbsp;<code>Vue.js<\/code>\uff0c\u5728\u6846\u67b6 SDK \u4e4b\u5916\uff0c\u5b8c\u6574\u7684\u6280\u672f\u4f53\u7cfb\u8fd8\u5305\u62ec\u5982\u4e0b\u8bbe\u65bd\u3002\n<\/p>\n<ul>\n<li>\n\t\t<a href=\"http:\/\/mpvue.com\/build\/mpvue-loader\" rel=\"nofollow\">mpvue-loader<\/a>&nbsp;\u63d0\u4f9b webpack \u7248\u672c\u7684\u52a0\u8f7d\u5668\n\t<\/li>\n<li>\n\t\t<a href=\"http:\/\/mpvue.com\/build\/mpvue-webpack-target\" rel=\"nofollow\">mpvue-webpack-target<\/a>&nbsp;webpack \u6784\u5efa\u76ee\u6807\n\t<\/li>\n<li>\n\t\t<a href=\"http:\/\/mpvue.com\/build\/postcss-mpvue-wxss\" rel=\"nofollow\">postcss-mpvue-wxss<\/a>&nbsp;\u6837\u5f0f\u4ee3\u7801\u8f6c\u6362\u9884\u5904\u7406\u5de5\u5177\n\t<\/li>\n<li>\n\t\t<a href=\"http:\/\/mpvue.com\/build\/px2rpx-loader\" rel=\"nofollow\">px2rpx-loader<\/a>&nbsp;\u6837\u5f0f\u8f6c\u5316\u63d2\u4ef6\n\t<\/li>\n<li>\n\t\t<a href=\"http:\/\/mpvue.com\/mpvue\/quickstart\" rel=\"nofollow\">mpvue-quickstart<\/a>&nbsp;mpvue-quickstart\n\t<\/li>\n<li>\n\t\t<a href=\"http:\/\/mpvue.com\/mpvue\/simple\" rel=\"nofollow\">mpvue-simple<\/a>&nbsp;\u8f85\u52a9 mpvue \u5feb\u901f\u5f00\u53d1 Page \/ Component \u7ea7\u5c0f\u7a0b\u5e8f\u9875\u9762\u7684\u5de5\u5177\n\t<\/li>\n<\/ul>\n<h2>\n\t\u5feb\u901f\u5165\u95e8<br \/>\n<\/h2>\n<p>\n\tmpvue \u7684\u5f00\u53d1\u73af\u5883\u9700\u8981 Node.js \u7684\uff0c\u5982\u679c\u6ca1\u6709\u7684\u8bdd\uff0c\u8bf7\u5148\u4e0b\u8f7d nodejs \u5e76\u5b89\u88c5\u3002\n<\/p>\n<p>\n\t\u7136\u540e\u6253\u5f00\u547d\u4ee4\u884c\u5de5\u5177\uff1a\n<\/p>\n<pre class=\"brush:bash;\">\r\n# 1. \u5148\u68c0\u67e5\u4e0b Node.js \u662f\u5426\u5b89\u88c5\u6210\u529f\r\n$ node -v\r\nv8.9.0\r\n\r\n$ npm -v\r\n5.6.0\r\n\r\n# 2. \u7531\u4e8e\u4f17\u6240\u5468\u77e5\u7684\u539f\u56e0\uff0c\u53ef\u4ee5\u8003\u8651\u5207\u6362\u6e90\u4e3a taobao \u6e90\r\n$ npm set registry https:\/\/registry.npm.taobao.org\/\r\n\r\n# 3. \u5168\u5c40\u5b89\u88c5 vue-cli\r\n# \u4e00\u822c\u662f\u8981 sudo \u6743\u9650\u7684\r\n$ npm install --global vue-cli\r\n\r\n# 4. \u521b\u5efa\u4e00\u4e2a\u57fa\u4e8e mpvue-quickstart \u6a21\u677f\u7684\u65b0\u9879\u76ee\r\n# \u65b0\u624b\u4e00\u8def\u56de\u8f66\u9009\u62e9\u9ed8\u8ba4\u5c31\u53ef\u4ee5\u4e86\r\n$ vue init mpvue\/mpvue-quickstart my-project\r\n\r\n# 5. \u5b89\u88c5\u4f9d\u8d56\uff0c\u8d70\u4f60\r\n$ cd my-project\r\n$ npm install\r\n$ npm run dev<\/pre>\n<p>\n\t\u968f\u7740\u8fd0\u884c\u6210\u529f\u7684\u56de\u663e\u4e4b\u540e\uff0c\u53ef\u4ee5\u770b\u5230\u672c\u5730\u591a\u4e86\u4e2a dist \u76ee\u5f55\uff0c\u8fd9\u4e2a\u76ee\u5f55\u91cc\u5c31\u662f\u751f\u6210\u7684\u5c0f\u7a0b\u5e8f\u76f8\u5173\u4ee3\u7801\u3002\n<\/p>\n<p>\n\t\u5c0f\u7a0b\u5e8f\u81ea\u5df1\u6709\u4e00\u4e2a\u4e13\u95e8\u7684\u5fae\u4fe1\u5f00\u53d1\u8005\u5de5\u5177\uff0c\u6700\u65b0\u7248\u672c\u4e0b\u8f7d\u5730\u5740\u3002\n<\/p>\n<p>\n\t\u8fd9\u4e00\u6b65\u6bd4\u8f83\u7b80\u5355\uff0c\u6309\u7167\u63d0\u793a\u4e00\u6b65\u6b65\u5b89\u88c5\u597d\u5c31\u884c\uff0c\u7136\u540e\u7528\u5fae\u4fe1\u626b\u63cf\u4e8c\u7ef4\u7801\u767b\u9646\u3002 \u81f3\u6b64\u5c0f\u7a0b\u5e8f\u7684\u5f00\u53d1\u73af\u5883\u5dee\u4e0d\u591a\u5b8c\u6210\u3002\n<\/p>\n<h2>\n\t\u8c03\u8bd5\u5f00\u53d1 mpvue<br \/>\n<\/h2>\n<p>\n\t\u9009\u62e9&nbsp;<code>\u5c0f\u7a0b\u5e8f\u9879\u76ee<\/code>&nbsp;\u5e76\u4f9d\u6b21\u586b\u597d\u9700\u8981\u7684\u4fe1\u606f\uff1a\n<\/p>\n<ul>\n<li>\n\t\t\u9879\u76ee\u76ee\u5f55\uff1a\u5c31\u662f\u524d\u6587\u63d0\u5230\u7684\u90a3\u4e2a&nbsp;<code>dist<\/code>&nbsp;\u76ee\u5f55\u3002\n\t<\/li>\n<li>\n\t\tAppID\uff1a\u6ca1\u6709\u7684\u8bdd\u53ef\u4ee5\u70b9\u9009\u4f53\u9a8c&ldquo;\u5c0f\u7a0b\u5e8f&rdquo;\uff0c\u53ea\u5f71\u54cd\u662f\u5426\u53ef\u4ee5\u771f\u673a\u8c03\u8bd5\u3002\n\t<\/li>\n<li>\n\t\t\u9879\u76ee\u540d\u79f0\u3002\n\t<\/li>\n<\/ul>\n<p>\n\t\u5982\u56fe\uff1a\n<\/p>\n<p>\n\t<img decoding=\"async\" alt=\"\u5c0f\u7a0b\u5e8f\u9879\u76ee\u914d\u7f6e\" src=\"http:\/\/mpvue.com\/assets\/quick-start\/1.png\" width=\"300\" \/>\n<\/p>\n<p>\n\t\u70b9\u51fb&ldquo;\u786e\u5b9a&rdquo;\u6309\u94ae\u540e\u4f1a\u8df3\u5230\u6b63\u5f0f\u7684\u5f00\u53d1\u9875\u9762\uff0c\u70b9\u51fb&ldquo;\u7f16\u8f91\u5668&rdquo;\u6309\u94ae\uff0c\u5173\u95ed\u81ea\u5e26\u7684\u5c0f\u7a0b\u5e8f\u7f16\u8f91\u5668\u3002\u7136\u540e\u5982\u56fe\uff1a\n<\/p>\n<p>\n\t<img decoding=\"async\" alt=\"mpvue-start\" src=\"http:\/\/mpvue.com\/assets\/quick-start\/2.png\" width=\"600\" \/>\n<\/p>\n<p>\n\t\u6b64\u65f6\uff0c\u6574\u4e2a&nbsp;<code>mpvue<\/code>&nbsp;\u9879\u76ee\u5df2\u7ecf\u8dd1\u8d77\u6765\u4e86\u3002\n<\/p>\n<p>\n\t\u7528\u81ea\u5df1\u8d81\u624b\u7684\u7f16\u8f91\u5668\uff08\u6216\u8005IDE\uff09\u6253\u5f00&nbsp;<code>my-project<\/code>&nbsp;\u4e2d\u7684&nbsp;<code>src<\/code>&nbsp;\u76ee\u5f55\u4e0b\u7684\u4ee3\u7801\u8bd5\u8bd5\u3002<\/p>\n<!-- <audio autoplay=\"autoplay\" height=\"100\" width=\"100\" hidden=\"true\"><source src=\"https:\/\/c.coka.la\/orAvPR.mp3\" type=\"audio\/mp3\"\/><\/audio><img decoding=\"async\" src=\"https:\/\/images.weserv.nl\/?url=https:\/\/ws3.sinaimg.cn\/large\/8fa5dcfcgy1g4em3rzar5j20ib089ae0.jpg\" alt=\"\u4e1a\u4f59\u8349\u516c\u4f17\u53f7\"\/> --><p><!-- <img decoding=\"async\" src=\"https:\/\/raw.githubusercontent.com\/xmt1139057136\/xttblog\/master\/8fa5dcfcgy1g4em3rzar5j20ib089ae0.jpg\" alt=\"\u4e1a\u4f59\u8349\u516c\u4f17\u53f7\"\/>--><img decoding=\"async\" src=\"https:\/\/saas.51autoparts.cn\/api\/admin\/sys-file\/oss\/file?fileName=84db51f8561e448f9a4fda2eff0811f9.jpg\" alt=\"\u4e1a\u4f59\u8349\u516c\u4f17\u53f7\"\/><\/p><p>\u6700\u540e\uff0c\u6b22\u8fce\u5173\u6ce8\u6211\u7684\u4e2a\u4eba\u5fae\u4fe1\u516c\u4f17\u53f7\uff1a\u4e1a\u4f59\u8349\uff08yyucao\uff09\uff01<b>\u53ef\u52a0\u4f5c\u8005\u5fae\u4fe1\u53f7\uff1a<font color=\"red\">xttblog2<\/font>\u3002\u5907\u6ce8\uff1a\u201c1\u201d\uff0c\u6dfb\u52a0\u535a\u4e3b\u5fae\u4fe1\u62c9\u4f60\u8fdb\u5fae\u4fe1\u7fa4\u3002\u5907\u6ce8\u9519\u8bef\u4e0d\u4f1a\u540c\u610f\u597d\u53cb\u7533\u8bf7\u3002<\/b>\u518d\u6b21\u611f\u8c22\u60a8\u7684\u5173\u6ce8\uff01\u540e\u7eed\u6709\u7cbe\u5f69\u5185\u5bb9\u4f1a\u7b2c\u4e00\u65f6\u95f4\u53d1\u7ed9\u60a8\uff01\u539f\u521b\u6587\u7ae0\u6295\u7a3f\u8bf7\u53d1\u9001\u81f3532009913@qq.com\u90ae\u7bb1\u3002\u5546\u52a1\u5408\u4f5c\u4e5f\u53ef\u6dfb\u52a0\u4f5c\u8005\u5fae\u4fe1\u8fdb\u884c\u8054\u7cfb\uff01<\/p><p>\u672c\u6587\u539f\u6587\u51fa\u5904\uff1a<a href=\"https:\/\/www.xttblog.com\">\u4e1a\u4f59\u8349<\/a>\uff1a &raquo; <a href=\"https:\/\/www.xttblog.com\/?p=2576\">\u7f8e\u56e2 mpvue \u6559\u7a0b<\/a><\/p><!-- <div class=\"bd-reward-stl\"><button id=\"bdRewardBtn\"><span><\/span><\/button><\/div> -->","protected":false},"excerpt":{"rendered":"<p>mpvue \u662f\u7f8e\u56e2\u5f00\u6e90\u7684\u4e00\u6b3e\u57fa\u4e8e Vue.js \u7684\u5c0f\u7a0b\u5e8f\u5f00\u53d1\u6846\u67b6\uff0c\u4ece\u5e95\u5c42\u652f\u6301 Vue.js \u8bed\u6cd5\u548c\u6784\u5efa\u5de5\u5177\u4f53\u7cfb [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[73,558,446,444,1432],"class_list":["post-2576","post","type-post","status-publish","format-standard","hentry","category-html5","tag-73","tag-558","tag-js-sdk","tag-444","tag-1432"],"_links":{"self":[{"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/posts\/2576","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2576"}],"version-history":[{"count":1,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/posts\/2576\/revisions"}],"predecessor-version":[{"id":2577,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/posts\/2576\/revisions\/2577"}],"wp:attachment":[{"href":"https:\/\/www.xttblog.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2576"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2576"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2576"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}