{"id":39014,"date":"2025-09-09T17:22:57","date_gmt":"2025-09-09T09:22:57","guid":{"rendered":"https:\/\/app.60day.cn\/appday\/?p=39014"},"modified":"2025-09-09T17:22:57","modified_gmt":"2025-09-09T09:22:57","slug":"%e7%94%a8vue%e5%81%9a%e4%ba%86%e4%b8%80%e6%ac%beapp%e6%80%8e%e4%b9%88%e4%b8%8a%e6%9e%b6%ef%bc%9f","status":"publish","type":"post","link":"https:\/\/app.60day.cn\/appday\/kaifaapp\/39014\/","title":{"rendered":"\u7528vue\u505a\u4e86\u4e00\u6b3eapp\u600e\u4e48\u4e0a\u67b6\uff1f"},"content":{"rendered":"<p>Vue\u662f\u4e00\u4e2a\u975e\u5e38\u6d41\u884c\u7684JavaScript\u6846\u67b6\uff0c\u7528\u4e8e\u6784\u5efa\u5355\u9875Web\u5e94\u7528\u7a0b\u5e8f\uff08SPA\uff09\u3002\u5b83\u662f\u4e00\u4e2a\u8f7b\u91cf\u7ea7\u4f46\u529f\u80fd\u5f3a\u5927\u7684\u6846\u67b6\uff0c\u5141\u8bb8\u5f00\u53d1\u4eba\u5458\u5feb\u901f\u6784\u5efa\u4ea4\u4e92\u5f0fWeb\u5e94\u7528\u7a0b\u5e8f\u3002\u5728\u672c\u6587\u4e2d\uff0c\u6211\u5c06\u4ecb\u7ecd\u5982\u4f55\u4f7f\u7528Vue\u6846\u67b6\u6784\u5efa\u4e00\u4e2a\u57fa\u672c\u7684Web\u5e94\u7528\u7a0b\u5e8f\u5e76\u5c06\u5176\u8f6c\u6362\u4e3a\u5e94\u7528\u7a0b\u5e8f\u3002<\/p>\n<p>\u8981\u6784\u5efa\u4e00\u4e2aVue\u5e94\u7528\u7a0b\u5e8f\uff0c\u9700\u8981\u4f7f\u7528Vue CLI\uff08\u547d\u4ee4\u884c\u754c\u9762\uff09\u5de5\u5177\u3002\u6211\u5c06\u4f7f\u7528Vue CLI 3\u6765\u521b\u5efa\u548c\u7ba1\u7406\u6211\u4eec\u7684Vue\u5e94\u7528\u7a0b\u5e8f\u9879\u76ee\u3002Vue CLI 3\u4e3a\u6211\u4eec\u63d0\u4f9b\u4e86\u4e00\u4e2a\u65b9\u4fbf\u7684\u65b9\u6cd5\u6765\u6784\u5efa\u548c\u7ba1\u7406Vue\u9879\u76ee\uff0c\u5b83\u4f7f\u7528Webpack 4\u6765\u6784\u5efa\u5e94\u7528\u7a0b\u5e8f\uff0c\u6240\u4ee5\u5b83\u5177\u6709\u5f88\u597d\u7684\u6027\u80fd\uff0c\u5e76\u4e14\u80fd\u591f\u5904\u7406\u5927\u91cf\u7684JavaScript\u548cCSS\u4ee3\u7801\u3002<\/p>\n<p>\u9996\u5148\uff0c\u9700\u8981\u5728\u8ba1\u7b97\u673a\u4e0a\u5b89\u88c5Vue CLI 3\u3002\u60a8\u53ef\u4ee5\u901a\u8fc7\u5728\u7ec8\u7aef\u4e2d\u8f93\u5165\u4ee5\u4e0b\u547d\u4ee4\u6765\u5b8c\u6210\u6b64\u64cd\u4f5c\uff1a<\/p>\n<p>npm install -g @vue\/cli<\/p>\n<p>\u63a5\u4e0b\u6765\uff0c\u6211\u4eec\u5c06\u4f7f\u7528Vue CLI 3\u6765\u521b\u5efa\u4e00\u4e2a\u65b0\u7684Vue\u9879\u76ee\u3002\u5728\u7ec8\u7aef\u4e2d\uff0c\u8fdb\u5165\u60a8\u60f3\u8981\u521b\u5efaVue\u5e94\u7528\u7a0b\u5e8f\u7684\u76ee\u5f55\uff0c\u5e76\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n<p>vue create my-app<\/p>\n<p>\u6b64\u547d\u4ee4\u5c06\u521b\u5efa\u4e00\u4e2a\u540d\u4e3amy-app\u7684\u65b0Vue\u5e94\u7528\u7a0b\u5e8f\uff0c\u5176\u4e2d\u5305\u542b\u5fc5\u8981\u7684\u6587\u4ef6\u548c\u76ee\u5f55\uff0c\u5305\u62ecApp.vue\uff0cmain.js\uff0cindex.html\u548cpackage.json\u6587\u4ef6\u3002<\/p>\n<p>\u5728\u8fd9\u4e2a\u5e94\u7528\u7a0b\u5e8f\u4e2d\uff0c\u6211\u5c06\u5c55\u793a\u5982\u4f55\u521b\u5efa\u4e00\u4e2a\u57fa\u672c\u7684\u8bb0\u4e8b\u672c\u5e94\u7528\u7a0b\u5e8f\uff0c\u53ef\u4ee5\u7528\u6765\u8bb0\u5f55\u5404\u79cd\u7c7b\u578b\u7684\u6587\u672c\u4fe1\u606f\u3002<\/p>\n<p>\u9996\u5148\uff0c\u5728App.vue\u6587\u4ef6\u4e2d\uff0c\u6211\u4eec\u5c06\u521b\u5efa\u4e00\u4e2a\u6587\u672c\u7f16\u8f91\u5668\u7ec4\u4ef6<a href=\"https:\/\/www.zhidianwl.com\/\">\u667a\u7535\u745e\u521b<\/a>\uff0c\u5176\u4e2d\u7528\u6237\u53ef\u4ee5\u8f93\u5165\u548c\u7f16\u8f91\u6587\u672c\u3002\u4ee5\u4e0b\u662f\u6211\u4eec\u5c06\u5728App.vue\u6587\u4ef6\u4e2d\u4f7f\u7528\u7684\u4ee3\u7801\uff1a<\/p>\n<p>\n<p>\n<p>    <textarea><\/textarea><\/p>\n<\/p>\n<\/p>\n<p>  export default {<\/p>\n<p>    data() {<a href=\"https:\/\/www.zhidianwl.com\/\">\u7f51\u7ad9\u505aapp<\/a><\/p>\n<p>      return {<\/p>\n<p>        text: &#8221;<\/p>\n<p>      }<\/p>\n<p>    }<\/p>\n<p>  }<\/p>\n<\/p>\n<p>\u5728\u8fd9\u4e2a\u7ec4\u4ef6\u4e2d\uff0c\u6211\u4eec\u521b\u5efa\u4e86\u4e00\u4e2a\u6587\u672c\u6846\uff0c\u4f7f\u7528\u6237\u53ef\u4ee5\u8f93\u5165\u6216\u7f16\u8f91\u6587\u672c\uff0c\u7136\u540e\u5c06\u5176\u7ed1\u5b9a\u5230Vue\u5b9e\u4f8b\u7684text\u5c5e\u6027\u4e2d\u3002\u6211\u4eec\u8fd8\u5bfc\u51fa\u4e86\u7ec4\u4ef6\u4f5c\u4e3a\u9ed8\u8ba4\u5bfc\u51fa\uff0c\u4ee5\u4fbf\u6211\u4eec\u53ef\u4ee5\u5728\u5176\u4ed6\u6587\u4ef6\u4e2d\u5f15\u7528\u5b83\u3002<\/p>\n<p>\u63a5\u4e0b\u6765\uff0c\u5728main.js\u6587\u4ef6\u4e2d\uff0c\u6211\u4eec\u5c06\u521b\u5efaVue\u5b9e\u4f8b\uff0c\u5e76\u5c06App.vue\u7ec4\u4ef6\u5bfc\u5165\u3002\u4ee5\u4e0b\u662f\u6211\u4eec\u5c06\u5728main.js\u6587\u4ef6\u4e2d\u4f7f\u7528\u7684\u4ee3\u7801\uff1a<\/p>\n<p>import Vue from &#8216;vue&#8217;<\/p>\n<p>i<\/p>\n<p><figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/cdn.myapp.ltd\/ag\/8\/sucai\/11.jpg\" \/><\/figure>\n<\/p>\n<p>mport App from &#8216;.\/App.vue&#8217;<\/p>\n<p>new Vue({<\/p>\n<p>  render: h =&gt; h(App)<\/p>\n<p>}).$mount(&#8216;#app&#8217;)<\/p>\n<p>\u5728\u8fd9\u4e2a\u6587\u4ef6\u4e2d\uff0c\u6211\u4eec\u5bfc\u5165Vue\u548cApp\u7ec4\u4ef6\uff0c\u5e76\u5728\u5b9e\u4f8b\u5316Vue\u65f6\u5c06App\u7ec4\u4ef6\u4f20\u9012\u7ed9render\u51fd\u6570\u3002\u6700\u540e\uff0c\u6211\u4eec\u5c06Vue\u5b9e\u4f8b\u6302\u8f7d\u5230id\u4e3a\u201capp\u201d\u7684HTML\u5143\u7d20\u4e0a\u3002<\/p>\n<p>\u73b0\u5728\uff0c\u6211\u4eec\u5df2\u7ecf\u521b\u5efa\u4e86\u4e00\u4e2a\u5305\u542b\u4e00\u4e2a\u6587\u672c\u6846\u7684Vue\u7ec4\u4ef6\uff0c\u5e76\u5c06\u5b83\u5305\u542b\u5728\u4e00\u4e2aVue\u5b9e\u4f8b\u4e2d\u3002\u63a5\u4e0b\u6765\uff0c\u6211\u4eec\u9700\u8981\u4f7f\u8fd9\u4e2a\u5e94\u7528\u7a0b\u5e8f\u50cf\u5e94\u7528\u7a0b\u5e8f\u4e00\u6837\u8fd0\u884c\u3002<\/p>\n<p>\u5728\u7ec8\u7aef\u4e2d\uff0c\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\uff0c\u5c06Vue\u5e94\u7528\u7a0b\u5e8f\u6784\u5efa\u4e3a\u5e94\u7528\u7a0b\u5e8f\u4ee3\u7801\uff1a<\/p>\n<p>vue build -m<\/p>\n<p>\u6b64\u547d\u4ee4\u5c06\u4f7f\u7528Vue CLI\u7684\u6784\u5efa\u529f\u80fd\u5c06\u5e94\u7528\u7a0b\u5e8f\u4ee3\u7801\u6253\u5305\u6210\u5355\u4e2aJavaScript\u6587\u4ef6\uff0c\u5e76\u5c06\u5176\u653e\u7f6e\u5728dist\u76ee\u5f55\u4e2d\u3002<\/p>\n<p>\u73b0\u5728\uff0c\u6211\u4eec\u9700\u8981\u5c06\u8fd9\u4e2a\u6253\u5305\u540e\u7684\u5e94\u7528\u7a0b\u5e8f\u4ee3\u7801\u8f6c\u6362\u4e3aiOS\u6216Android\u5e94\u7528\u7a0b\u5e8f\u3002\u4e3a\u6b64\uff0c\u6211\u4eec\u5c06\u4f7f\u7528Apache Cordova\u6846\u67b6\u3002<\/p>\n<p>\u8981\u4f7f\u7528Cordova\uff0c\u60a8\u9700\u8981\u5728\u8ba1\u7b97\u673a\u4e0a\u5b89\u88c5\u5b83\u4ee5\u53ca\u6240\u9700\u7684\u4f9d\u8d56\u9879\u3002\u60a8\u53ef\u4ee5\u6309\u7167Cordova\u6587\u6863\u4e2d\u7684\u8bf4\u660e\u8fdb\u884c\u5b89\u88c5\u3002<\/p>\n<p>\u4e00\u65e6\u5b89\u88c5\u4e86Cordova\uff0c\u60a8\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u5728\u4e00\u4e2a\u65b0\u76ee\u5f55\u4e2d\u521b\u5efaCordova\u9879\u76ee\uff1a<\/p>\n<p>cordova create my-app com.example.myapp MyApp<\/p>\n<p>\u8fd9\u5c06\u521b\u5efa\u540d\u4e3amy-app\u7684\u65b0Cordova\u9879\u76ee\uff0c\u5e76\u5c06\u5176\u5305\u542b\u5728\u4e00\u4e2a\u540d\u4e3aMyApp\u7684\u5e94\u7528\u7a0b\u5e8f\u5305\u4e2d\u3002\u63a5\u4e0b\u6765\uff0c\u60a8\u9700\u8981\u8fdb\u5165my-app\u76ee\u5f55\uff0c\u7136\u540e\u5c06Vue\u6253\u5305\u5e94\u7528\u7a0b\u5e8f\u4e2d\u7684\u6240\u6709\u6587\u4ef6\u590d\u5236\u5230Cordova\u9879\u76ee\u7684www\u76ee\u5f55\u4e2d\u3002<\/p>\n<p>\u5728\u7ec8\u7aef\u4e2d\uff0c\u8fdb\u5165\u6253\u5305\u5e94\u7528\u7a0b\u5e8f\u7684\u76ee\u5f55\uff0c\u5e76\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n<p>cp -r dist\/* \/path\/to\/my-app\/www\/<\/p>\n<p>\u6b64\u547d\u4ee4\u5c06\u590d\u5236\u6253\u5305\u540e\u7684\u6240\u6709\u5e94\u7528\u7a0b\u5e8f\u4ee3\u7801\u6587\u4ef6\uff08\u5305\u62ecindex.html\u548capp.js\uff09\u5230Cordova\u9879\u76ee\u7684www\u76ee\u5f55\u4e2d\u3002<\/p>\n<p>\u73b0\u5728\uff0c\u6211\u4eec\u9700\u8981\u4e3aAndroid\u6216iOS\u5e73\u53f0\u6784\u5efaCordova\u5e94\u7528\u7a0b\u5e8f\u3002\u8fd9\u4e2a\u8fc7\u7a0b\u662f\u5e73\u53f0\u7279\u5b9a\u7684\uff0c\u56e0\u6b64\u8bf7\u6309\u7167Cordova\u6587\u6863\u4e2d\u63cf\u8ff0\u7684\u8bf4\u660e\u8fdb\u884c\u3002<\/p>\n<p>\u4e00\u65e6\u5b8c\u6210\u4e86\u6784\u5efaiOS\u6216Android\u5e94\u7528\u7a0b\u5e8f\u7684\u8fc7\u7a0b\uff0c\u60a8\u5c31\u53ef\u4ee5\u5b89\u88c5\u5e76\u8fd0\u884c\u8be5\u5e94\u7528\u7a0b\u5e8f\u4e86\uff01<\/p>\n<p>\u603b\u4e4b\uff0c\u5229\u7528Vue\u6846\u67b6\u548cCordova\u79fb\u52a8\u5e94\u7528\u7a0b\u5e8f\u5e73\u53f0\uff0c\u6211\u4eec\u53ef\u4ee5\u975e\u5e38\u5feb\u901f\u5730\u6784\u5efa\u4e00\u4e2a\u8bb0\u4e8b\u672c\u5e94\u7528\u7a0b\u5e8f\u3002Vue\u63d0\u4f9b\u4e86\u4e00\u4e2a\u7075\u6d3b\u800c\u5f3a\u5927\u7684\u5f00\u53d1\u73af\u5883\uff0c\u800cCordova\u5219\u63d0\u4f9b\u4e86\u5c06Web\u5e94\u7528\u7a0b\u5e8f\u8f6c\u6362\u4e3a\u672c\u5730\u5e94\u7528\u7a0b\u5e8f\u7684\u529f\u80fd\u3002\u4f7f\u7528\u8fd9\u4e9b\u5de5\u5177\uff0c\u5f00\u53d1\u4eba\u5458\u53ef\u4ee5\u66f4\u5feb\u5730\u6784\u5efa\u51fa\u7cbe\u7f8e\u7684\u5e94\u7528\u7a0b\u5e8f\uff0c\u5e76\u4e14\u53ef\u4ee5\u5c06\u5b83\u4eec\u4f20\u9012\u7ed9\u7528\u6237\uff0c\u8ba9\u7528\u6237\u53ef\u4ee5\u901a\u8fc7\u5e94\u7528\u5546\u5e97\u4e0b\u8f7d\u548c\u4f7f\u7528\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Vue\u662f\u4e00\u4e2a\u975e\u5e38\u6d41\u884c\u7684JavaScript\u6846\u67b6\uff0c\u7528\u4e8e\u6784\u5efa\u5355\u9875Web\u5e94\u7528\u7a0b\u5e8f\uff08SPA\uff09\u3002\u5b83\u662f\u4e00\u4e2a\u8f7b\u91cf\u7ea7\u4f46\u529f\u80fd\u5f3a\u5927\u7684\u6846\u67b6\uff0c\u5141\u8bb8\u5f00\u53d1\u4eba\u5458\u5feb\u901f\u6784\u5efa\u4ea4\u4e92\u5f0fWeb\u5e94\u7528\u7a0b\u5e8f\u3002\u5728\u672c\u6587\u4e2d\uff0c\u6211\u5c06\u4ecb\u7ecd\u5982\u4f55\u4f7f\u7528Vue\u6846\u67b6\u6784<\/p>\n","protected":false},"author":20,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[34902,34903,166,84,132],"topic":[],"class_list":["post-39014","post","type-post","status-publish","format-standard","hentry","category-kaifaapp","tag-vueapp","tag-app","tag-166","tag-84","tag-132"],"_links":{"self":[{"href":"https:\/\/app.60day.cn\/appday\/wp-json\/wp\/v2\/posts\/39014","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/app.60day.cn\/appday\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/app.60day.cn\/appday\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/app.60day.cn\/appday\/wp-json\/wp\/v2\/users\/20"}],"replies":[{"embeddable":true,"href":"https:\/\/app.60day.cn\/appday\/wp-json\/wp\/v2\/comments?post=39014"}],"version-history":[{"count":1,"href":"https:\/\/app.60day.cn\/appday\/wp-json\/wp\/v2\/posts\/39014\/revisions"}],"predecessor-version":[{"id":39041,"href":"https:\/\/app.60day.cn\/appday\/wp-json\/wp\/v2\/posts\/39014\/revisions\/39041"}],"wp:attachment":[{"href":"https:\/\/app.60day.cn\/appday\/wp-json\/wp\/v2\/media?parent=39014"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/app.60day.cn\/appday\/wp-json\/wp\/v2\/categories?post=39014"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/app.60day.cn\/appday\/wp-json\/wp\/v2\/tags?post=39014"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/app.60day.cn\/appday\/wp-json\/wp\/v2\/topic?post=39014"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}