{"id":183978,"date":"2020-10-28T15:27:35","date_gmt":"2020-10-28T07:27:35","guid":{"rendered":"http:\/\/4563.org\/?p=183978"},"modified":"2020-10-28T15:27:35","modified_gmt":"2020-10-28T07:27:35","slug":"vue-%e8%a1%a8%e5%8d%95%e5%9c%ba%e6%99%af%e4%bd%bf%e7%94%a8-v-if-%e5%92%8c%e6%98%af-v-show","status":"publish","type":"post","link":"http:\/\/4563.org\/?p=183978","title":{"rendered":"Vue \u8868\u5355\u573a\u666f\u4f7f\u7528 v-if \u548c\u662f v-show"},"content":{"rendered":"<div>\n<div>\n<div>\n<h1>                  Vue \u8868\u5355\u573a\u666f\u4f7f\u7528 v-if \u548c\u662f v-show               <\/h1>\n<p> <\/p>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : lvming6816077 <\/span>  <span><i><\/i> 5<\/span> <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<\/p><\/div>\n<div isfirst=\"1\"> <\/p>\n<p>\u4f8b\u5982\u8868\u5355\u903b\u8f91\u6709\u5f88\u591a\u5b57\u6bb5\uff0c\u4f46\u662f\u8fd9\u4e9b\u5b57\u6bb5\u6709\u6743\u9650\u903b\u8f91\u5224\u65ad\uff0c\u5373 A \u7528\u6237\u770b\u5230\u7684\u5b57\u6bb5\u548c B \u7528\u6237\u770b\u5230\u7684\u5b57\u6bb5\u4e0d\u4e00\u6837\uff0c\u6240\u4ee5\u5c31\u4f1a\u6d89\u53ca\u5230\u4f7f\u7528 v-if \u8fd8\u662f v-show \u6765\u663e\u793a\u548c\u9690\u85cf\u4e00\u4e9b\u5b57\u6bb5\u3002 \u4f46\u662f\u6d89\u53ca\u5230\u63d0\u4ea4\u65f6\u8981\u505a\u4e00\u4e9b\u683c\u5f0f\u7684\u6821\u9a8c\uff0c\u90a3\u8fd9\u6837\u5c31\u4e5f\u9700\u8981\u505a\u4e00\u4e0b\u6743\u9650\u903b\u8f91\u5224\u65ad\uff0c\u5982\u679c\u7528 v-if \u7684\u8bdd\u5c31\u9700\u8981\u5224\u65ad\u5f53\u524d\u7684\u8868\u5355\u63a7\u4ef6\u5bf9\u5e94\u7684 model \u662f\u5426\u5b58\u5728\uff0cv-show \u7684\u8bdd\u5c31\u4e0d\u9700\u8981\u3002 \u8fd9\u91cc\u7528\u54ea\u79cd\u597d\u4e00\u4e9b\u5462\uff1f<\/p>\n<\/p><\/div>\n<div> <b>\u5927\u4f6c\u6709\u8a71\u8aaa<\/b> (<span>2<\/span>)        <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<ul>\n<li data-pid=\"3964589\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : imydou <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             v-show \u5c31\u662f display: none \u6807\u7b7e\u8fd8\u5728                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"3964590\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : jevonszmx <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u5b98\u65b9\u6587\u6863\uff1a<\/p>\n<p>v-if vs v-show<br \/>v-if \u662f\u201c\u771f\u6b63\u201d\u7684\u6761\u4ef6\u6e32\u67d3\uff0c\u56e0\u4e3a\u5b83\u4f1a\u786e\u4fdd\u5728\u5207\u6362\u8fc7\u7a0b\u4e2d\u6761\u4ef6\u5757\u5185\u7684\u4e8b\u4ef6\u76d1\u542c\u5668\u548c\u5b50\u7ec4\u4ef6\u9002\u5f53\u5730\u88ab\u9500\u6bc1\u548c\u91cd\u5efa\u3002<\/p>\n<p>v-if \u4e5f\u662f\u60f0\u6027\u7684\uff1a\u5982\u679c\u5728\u521d\u59cb\u6e32\u67d3\u65f6\u6761\u4ef6\u4e3a\u5047\uff0c\u5219\u4ec0\u4e48\u4e5f\u4e0d\u505a\u2014\u2014\u76f4\u5230\u6761\u4ef6\u7b2c\u4e00\u6b21\u53d8\u4e3a\u771f\u65f6\uff0c\u624d\u4f1a\u5f00\u59cb\u6e32\u67d3\u6761\u4ef6\u5757\u3002<\/p>\n<p>\u76f8\u6bd4\u4e4b\u4e0b\uff0cv-show \u5c31\u7b80\u5355\u5f97\u591a\u2014\u2014\u4e0d\u7ba1\u521d\u59cb\u6761\u4ef6\u662f\u4ec0\u4e48\uff0c\u5143\u7d20\u603b\u662f\u4f1a\u88ab\u6e32\u67d3\uff0c\u5e76\u4e14\u53ea\u662f\u7b80\u5355\u5730\u57fa\u4e8e CSS \u8fdb\u884c\u5207\u6362\u3002<\/p>\n<p>\u4e00\u822c\u6765\u8bf4\uff0cv-if \u6709\u66f4\u9ad8\u7684\u5207\u6362\u5f00\u9500\uff0c\u800c v-show \u6709\u66f4\u9ad8\u7684\u521d\u59cb\u6e32\u67d3\u5f00\u9500\u3002\u56e0\u6b64\uff0c\u5982\u679c\u9700\u8981\u975e\u5e38\u9891\u7e41\u5730\u5207\u6362\uff0c\u5219\u4f7f\u7528 v-show \u8f83\u597d\uff1b\u5982\u679c\u5728\u8fd0\u884c\u65f6\u6761\u4ef6\u5f88\u5c11\u6539\u53d8\uff0c\u5219\u4f7f\u7528 v-if \u8f83\u597d\u3002<\/p>\n<p>\u6309\u7167\u4f60\u7684\u9700\u6c42\uff0c\u4e0d\u5efa\u8bae\u7528 v-show\uff0c\u56e0\u4e3a v-show \u662f\u57fa\u4e8e css \u5207\u6362\u663e\u793a\u548c\u9690\u85cf\uff0c\u67e5\u770b dom \u5185\u5bb9\u5c31\u66b4\u9732\u4e86\u3002                                                            <\/p><\/div>\n<\/p><\/div>\n<\/li>\n<li>\n","protected":false},"excerpt":{"rendered":"<p>Vue \u8868\u5355\u573a\u666f\u4f7f\u7528 v-if \u548c&hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[],"tags":[],"_links":{"self":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/183978"}],"collection":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=183978"}],"version-history":[{"count":0,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/183978\/revisions"}],"wp:attachment":[{"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=183978"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=183978"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=183978"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}