{"id":1058,"date":"2023-03-12T10:13:50","date_gmt":"2023-03-12T02:13:50","guid":{"rendered":"https:\/\/www.appblog.cn\/?p=1058"},"modified":"2023-04-29T11:47:42","modified_gmt":"2023-04-29T03:47:42","slug":"vue-development-skills","status":"publish","type":"post","link":"https:\/\/www.appblog.cn\/index.php\/2023\/03\/12\/vue-development-skills\/","title":{"rendered":"Vue\u5f00\u53d1\u6280\u5de7"},"content":{"rendered":"<h3>Vue\u9879\u76ee\u4e2d\u8df3\u8f6c\u5230\u5916\u90e8\u94fe\u63a5\u65b9\u6cd5<\/h3>\n<p>Vue\u9875\u9762\u4e2d\u7684\u5185\u90e8\u8df3\u8f6c\uff0c\u53ef\u4ee5\u7528 <code>this.$router.push()<\/code> \u5b9e\u73b0\uff0c\u4f46\u662f\u5982\u679c\u6211\u4eec\u8fd8\u7528\u8fd9\u79cd\u65b9\u6cd5\u8df3\u8f6c\u5916\u90e8\u94fe\u63a5\uff0c\u5c31\u4f1a\u62a5\u9519\uff0c\u4e00\u770b\u94fe\u63a5\u7684\u8def\u5f84\uff0c\u539f\u6765\u662f\u5728\u5916\u90e8\u94fe\u63a5\u524d\u9762\u52a0\u4e0a\u4e86 <code>http:\/\/localhost:8080\/#\/<\/code> \u8fd9\u4e00\u4e32\u5bfc\u81f4\u8df3\u8f6c\u51fa\u73b0\u95ee\u9898\uff0c\u90a3\u4e48\u6211\u4eec\u5982\u4f55\u8df3\u8f6c\u5230\u5916\u90e8\u94fe\u63a5\u5462\uff0c\u53ea\u9700\u4f7f\u7528JavaScript\u539f\u751f\u8df3\u8f6c\u65b9\u5f0f\u5b9e\u73b0\u5373\u53ef\uff1a<\/p>\n<pre><code class=\"language-javascript\">window.location.href = &#039;url&#039;<\/code><\/pre>\n<p><!-- more --><\/p>\n<h3>vue-cli\u57df\u540d\u8bbf\u95eeInvalid Host header<\/h3>\n<p>\u5728webpack.dev.conf.js\u4e2d\u6dfb\u52a0\uff1a<code>disableHostCheck: true<\/code><\/p>\n<pre><code class=\"language-javascript\">const devWebpackConfig = merge(baseWebpackConfig, {\n  ...\n\n  \/\/ these devServer options should be customized in \/config\/index.js\n  devServer: {\n    disableHostCheck: true,\n    ...<\/code><\/pre>\n<h3>\u5168\u5c40\u7f13\u5b58\u4e0e\u6d4f\u89c8\u5668\u7a97\u53e3\u7f13\u5b58<\/h3>\n<pre><code class=\"language-javascript\">var openId = global.localStorage.getItem(&#039;open_id&#039;)\nglobal.localStorage.setItem(&#039;open_id&#039;, openId)<\/code><\/pre>\n<pre><code class=\"language-javascript\">var openId = window.localStorage.getItem(&#039;open_id&#039;)\nwindow.localStorage.setItem(&#039;open_id&#039;, openId)<\/code><\/pre>\n<h3><code>$router<\/code>\u8df3\u8f6c\u53ca\u4f20\u53c2<\/h3>\n<ul>\n<li><strong>path+query<\/strong><\/li>\n<\/ul>\n<pre><code class=\"language-javascript\">this.$router.push({path: &#039;\/wx_error&#039;, query: {msg: &#039;open_id error&#039;}}) \/\/ $route.query.msg<\/code><\/pre>\n<p>\u8df3\u8f6cURL\uff1a<code>http:\/\/192.168.1.88:8080\/wx_error?msg=open_id error<\/code><br \/>\n\u63a5\u6536\u53c2\u6570\uff1a<code>{% raw %}{{ $route.query.msg }}{% endraw %}<\/code><\/p>\n<ul>\n<li><strong>name+params<\/strong><\/li>\n<\/ul>\n<pre><code class=\"language-javascript\">this.$router.push({name: &#039;wx_error&#039;, params: {msg: &#039;open_id error&#039;}}) \/\/ $route.params.msg<\/code><\/pre>\n<p>\u8df3\u8f6cURL\uff1a<code>http:\/\/192.168.1.88:8080\/wx_error<\/code><br \/>\n\u63a5\u6536\u53c2\u6570\uff1a<code>{% raw %}{{ $route.params.msg }}{% endraw %}<\/code><\/p>\n<h3>\u5b9a\u65f6\u4efb\u52a1<\/h3>\n<pre><code class=\"language-javascript\">data () {\n  return {\n    myInterval: null\n  }\n},\nmounted () {\n  let _this = this\n  this.myInterval = window.setInterval(function () {\n    _this.myMethod()\n  }, 1000)\n},\nbeforeDestroy () {\n  window.clearInterval(this.myInterval)\n},\nmethods: {\n  myMethod () {\n    ...\n  }\n}<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Vue\u9879\u76ee\u4e2d\u8df3\u8f6c\u5230\u5916\u90e8\u94fe\u63a5\u65b9\u6cd5 Vue\u9875\u9762\u4e2d\u7684\u5185\u90e8\u8df3\u8f6c\uff0c\u53ef\u4ee5\u7528 this.$router.push() \u5b9e\u73b0\uff0c [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[35],"tags":[],"class_list":["post-1058","post","type-post","status-publish","format-standard","hentry","category-vue"],"_links":{"self":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts\/1058","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/comments?post=1058"}],"version-history":[{"count":0,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts\/1058\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/media?parent=1058"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/categories?post=1058"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/tags?post=1058"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}