{"id":1160,"date":"2023-06-17T17:18:00","date_gmt":"2023-06-17T09:18:00","guid":{"rendered":"http:\/\/blog.xrhoujie.com\/?p=1160"},"modified":"2023-05-26T14:41:03","modified_gmt":"2023-05-26T06:41:03","slug":"vue-%e6%8b%bc%e5%9b%a2%e7%a7%92%e6%9d%80%e5%80%92%e8%ae%a1%e6%97%b6%e7%bb%84%e4%bb%b6%e5%b0%81%e8%a3%85","status":"publish","type":"post","link":"http:\/\/blog.xrhoujie.com\/?p=1160","title":{"rendered":"vue-\u62fc\u56e2\u79d2\u6740\u5012\u8ba1\u65f6\u7ec4\u4ef6\u5c01\u88c5"},"content":{"rendered":"\n<p>\u524d\u6bb5\u65f6\u95f4\u505a\u4e86\u4e00\u4e2aweb\u5c0f\u7a0b\u5e8f\u9879\u76ee\uff0c\u4e1a\u52a1\u4e0a\u6709\u5012\u8ba1\u65f6  xx\u5929xx\u65f6xx\u5206xx\u79d2\u9700\u6c42\uff0c\u6240\u4ee5\u54b1\u5c31\u5f00\u59cb\u52a8\u624b\u62c6\u5206-\u5c01\u88c5\u3002<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" width=\"191\" height=\"88\" src=\"http:\/\/blog.xrhoujie.com\/wp-content\/uploads\/2023\/03\/image-4.png\" alt=\"\" class=\"wp-image-1161\"\/><\/figure>\n\n\n\n<p>\u7236\u7ec4\u4ef6\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;template>\n   &lt;view>\n      &lt;countDown :endTime=\"<meta charset=\"utf-8\">goodsList&#91;0].endTime\" :endText=\"<meta charset=\"utf-8\">goodsList&#91;0].endText \"  class=\"timer-text\"\/>\t\t\t\n   &lt;\/view>\n\t\n&lt;\/template>\n\n&lt;script>\n\timport countDown from \"..\/..\/components\/countDown\/countDown.vue\"\n\texport default {\n\t\tcomponents:{\n\t\t\tcountDown,\n\t\t},\n\t\t\n\t\tdata() {\n\t\t   return {\n\t\t\tgoodsList:&#91;{ \/\/ type:0 \u662f\u62fc\u56e2\u5546\u54c1\uff0c1\u662f\u666e\u901a\u5546\u54c1\uff0c tips:true\u7279\u60e0\u6807\u8bc6\n\t\t\t\ttype:0,\n\t\t\t\turl:require('..\/..\/..\/..\/static\/\/images\/4.jpg'),\n\t\t\t\ttitle:'\u9752\u5c11\u5e74\u3010\u6807\u51c6\u3011\u5546\u54c1\u5957\u9910',\n\t\t\t\ttips:true,\n\t\t\t\told_price:199,\n\t\t\t\tnew_price:155,\n\t\t\t\tlast_price:'',\n\t\t\t\tpeople_buy:'291',\n\t\t\t\tendTime:new Date(\"2023\/04\/18 11:00:00\").getTime() \/ 1000 +  ' ', \/\/---\u540e\u53f0\u7ed9\u6beb\u79d2\u66f4\u65b9\u4fbf\n\t\t\t\t\/\/ \/\/  console.log(endTime)=>\u5f97\u5230\u6beb\u79d2  1658030420 \u53ef\u5728\u65b9\u6cd5\u91cc\u9762\u653e\u5165\u540e\u53f0\u6570\u636e,new Date('\u653e\u540e\u53f0\u6570\u636e').getTime() \/ 1000 +  ' ',\u4f46\u8981\u8bb0\u5f97\u8c03\u7528\u65b9\u6cd5\n\t\t\t\tendText:'',\n\t\t\t}]\n\t\t\t}\n\t\t},\n\t\tmethods: {\n\t\t\n\t\t},\n\t\tcreated(){\n\t\t\t\t\t\t\/\/ console.log(this.goodsList)\n\t\t},\n\t\tonLoad(param) {\n\t\t\t\n\t\t}\n\t}\r\n\n&lt;\/script>\n\n\n<\/code><\/pre>\n\n\n\n<p>\u5b50\u7ec4\u4ef6\u4e0a\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;template>\n\t&lt;!--endTime:\u4f20\u5165\u6beb\u79d2\uff0c endText:\u65f6\u95f4\u7ed3\u675f\u540e\uff1a\u672c\u6b21\u6d3b\u52a8\u5df2\u7ed3\u675f\u3002endTip:string \u4f20\u51651\uff0c\u6837\u5f0f\u4e3a \u4ec5\u5269xx\u5929:xx\u65f6:xx\u5206\uff0c\u9ed8\u8ba4\u4e3a\u7a7a xx\u5929:xx\u65f6:xx\u5206\uff0c -->\n\t&lt;p :endTime=\"endTime\" :endText=\"endText\" :endTip=\"endTip\">\n\t\t&lt;slot>{{content}}&lt;\/slot>\n\t&lt;\/p>\n&lt;\/template>\n\n&lt;script>\n\texport default {\n\t\tdata(){\n\t\t\treturn {\n\t\t\t\tcontent: '',\n\t\t\t}\n\t\t},\n\t\tprops:{\/\/\u63a5\u6536\u7236\u7ec4\u4ef6\u7684\u6570\u636e\n\t\t\tendTime:{type:String,default:''},\n\t\t\tendText:{type:String,default:'\u6d3b\u52a8\u5df2\u7ed3\u675f'},\n\t\t\tendTip:{type:String,default:''}\n\t\t},\n\t\twatch: {\/\/\u76d1\u542c\u65f6\u95f4\u7684\u53d8\u5316\n\t\t\tendTime() {\n\t\t\t\tthis.countdowm(this.endTime)\n\t\t\t}\n\t\t},\n\t\tmounted () {\n\t\t\tthis.initCountDown(this.endTime)\n\t\t\tthis.countdowm(this.endTime)\n\t\t},\n\t\tmethods: {\n\t\t\tcountdowm(timestamp){\n\t\t\t\tlet self = this;\n\t\t\t\tlet timer = setInterval(function(){\n\t\t\t\t\tlet nowTime = new Date();\n\t\t\t\t\tlet endTime = new Date(timestamp * 1000);\n\t\t\t\t\tlet t = endTime.getTime() - nowTime.getTime();\n\t\t\t\t\tif(t>0){\n\t\t\t\t\t\tlet day = Math.floor(t\/86400000);\n\t\t\t\t\t\tlet hour=Math.floor((t\/3600000)%24);\n\t\t\t\t\t\tlet min=Math.floor((t\/60000)%60);\n\t\t\t\t\t\tlet sec=Math.floor((t\/1000)%60);\n\t\t\t\t\t\thour = hour &lt; 10 ? \"0\" + hour : hour;\n\t\t\t\t\t\tmin = min &lt; 10 ? \"0\" + min : min;\n\t\t\t\t\t\tsec = sec &lt; 10 ? \"0\" + sec : sec;\n\t\t\t\t\t\tlet format = '';\n\t\t\t\t\t\tif(day > 0){\n\t\t\t\t\t\t\t\/\/ format = `${day}\u5929${hour}\u5c0f\u65f6${min}\u5206${sec}\u79d2`;\n\t\t\t\t\t\t\tformat = `${day}\u5929${hour}\u5c0f\u65f6${min}\u5206`;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif(day &lt;= 0 &amp;&amp; hour > 0 ){\n\t\t\t\t\t\t\t\/\/ format = `00\u5929${hour}\u5c0f\u65f6${min}\u5206${sec}\u79d2`;\n\t\t\t\t\t\t\tformat = `00\u5929${hour}\u5c0f\u65f6${min}\u5206`;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif(day &lt;= 0 &amp;&amp; hour &lt;= 0){\n\t\t\t\t\t\t\t\/\/ format =`00\u592900\u5c0f\u65f6${min}\u5206${sec}\u79d2`;\n\t\t\t\t\t\t\t\tformat =`00\u592900\u5c0f\u65f6${min}\u5206`;\n\t\t\t\t\t\t}\n\t\t\t\t\t\t\/\/ self.content = format;\n\t\t\t\t\t\tif(self.endTip === '1'){\n\t\t\t\t\t\t\tself.content = '\u4ec5\u5269 '+format;\n\t\t\t\t\t\t}else{\n\t\t\t\t\t\t\tself.content = format;\n\t\t\t\t\t\t}\n\t\t\t\t\t}else{\n\t\t\t\t\t\tclearInterval(timer);\n\t\t\t\t\t\tself.content = self.endText;\n\t\t\t\t\t}\n\t\t\t\t},1000);\n\t\t\t},\n\t\t\tinitCountDown(timestamp){\n\t\t\t\tlet self = this;\n\t\t\t\t\tlet nowTime = new Date();\n\t\t\t\t\tlet endTime = new Date(timestamp * 1000);\n\t\t\t\t\tlet t = endTime.getTime() - nowTime.getTime();\n\t\t\t\t\tif(t>0){\n\t\t\t\t\t\tlet day = Math.floor(t\/86400000);\n\t\t\t\t\t\tlet hour=Math.floor((t\/3600000)%24);\n\t\t\t\t\t\tlet min=Math.floor((t\/60000)%60);\n\t\t\t\t\t\tlet sec=Math.floor((t\/1000)%60);\n\t\t\t\t\t\thour = hour &lt; 10 ? \"0\" + hour : hour;\n\t\t\t\t\t\tmin = min &lt; 10 ? \"0\" + min : min;\n\t\t\t\t\t\tsec = sec &lt; 10 ? \"0\" + sec : sec;\n\t\t\t\t\t\tlet format = '';\n\t\t\t\t\t\tif(day > 0){\n\t\t\t\t\t\t\t\/\/ format = `${day}\u5929${hour}\u5c0f\u65f6${min}\u5206${sec}\u79d2`;\n\t\t\t\t\t\t\tformat = `${day}\u5929${hour}\u5c0f\u65f6${min}\u5206`;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif(day &lt;= 0 &amp;&amp; hour > 0 ){\n\t\t\t\t\t\t\t\/\/ format = `00\u5929${hour}\u5c0f\u65f6${min}\u5206${sec}\u79d2`;\n\t\t\t\t\t\t\tformat = `00\u5929${hour}\u5c0f\u65f6${min}\u5206`;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif(day &lt;= 0 &amp;&amp; hour &lt;= 0){\n\t\t\t\t\t\t\t\/\/ format =`00\u592900\u5c0f\u65f6${min}\u5206${sec}\u79d2`;\n\t\t\t\t\t\t\t\tformat =`00\u592900\u5c0f\u65f6${min}\u5206`;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif(self.endTip === '1'){\n\t\t\t\t\t\t\tself.content = '\u4ec5\u5269 '+format;\n\t\t\t\t\t\t}else{\n\t\t\t\t\t\t\tself.content = format;\n\t\t\t\t\t\t}\n\t\t\t\t\t}else{\n\t\t\t\t\t\tself.content = self.endText;\n\t\t\t\t\t}\n\t\t\t},\n\t\t\t\n\t\t}\n\t}\n&lt;\/script>\n<\/code><\/pre>\n\n\n\n<p><\/p>\n\n\n\n<p>\u7ed3\u675f\uff0c<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u524d\u6bb5\u65f6\u95f4\u505a\u4e86\u4e00\u4e2aweb\u5c0f\u7a0b\u5e8f\u9879\u76ee\uff0c\u4e1a\u52a1\u4e0a\u6709\u5012\u8ba1\u65f6 xx\u5929xx\u65f6xx\u5206xx\u79d2\u9700\u6c42\uff0c\u6240\u4ee5\u54b1\u5c31\u5f00\u59cb\u52a8\u624b\u62c6\u5206-\u5c01\u88c5\u3002  [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[41],"tags":[38],"_links":{"self":[{"href":"http:\/\/blog.xrhoujie.com\/index.php?rest_route=\/wp\/v2\/posts\/1160"}],"collection":[{"href":"http:\/\/blog.xrhoujie.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/blog.xrhoujie.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/blog.xrhoujie.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/blog.xrhoujie.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1160"}],"version-history":[{"count":1,"href":"http:\/\/blog.xrhoujie.com\/index.php?rest_route=\/wp\/v2\/posts\/1160\/revisions"}],"predecessor-version":[{"id":1162,"href":"http:\/\/blog.xrhoujie.com\/index.php?rest_route=\/wp\/v2\/posts\/1160\/revisions\/1162"}],"wp:attachment":[{"href":"http:\/\/blog.xrhoujie.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1160"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/blog.xrhoujie.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1160"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/blog.xrhoujie.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1160"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}