{"id":150608,"date":"2020-09-03T04:58:17","date_gmt":"2020-09-02T20:58:17","guid":{"rendered":"http:\/\/4563.org\/?p=150608"},"modified":"2020-09-03T04:58:17","modified_gmt":"2020-09-02T20:58:17","slug":"%e6%9c%89%e4%bb%80%e4%b9%88-vue3typescript-%e5%bc%80%e5%8f%91%e7%9a%84%e7%bb%84%e4%bb%b6%ef%bc%8c%e5%8f%91%e5%b8%83%e4%b8%ba-npm-%e5%8c%85%e7%9a%84%e8%af%a6%e5%b0%bd%e6%8c%87%e5%8d%97%e5%8f%af","status":"publish","type":"post","link":"http:\/\/4563.org\/?p=150608","title":{"rendered":"\u6709\u4ec0\u4e48 vue3+typescript \u5f00\u53d1\u7684\u7ec4\u4ef6\uff0c\u53d1\u5e03\u4e3a npm \u5305\u7684\u8be6\u5c3d\u6307\u5357\u53ef\u4f9b\u5b66\u4e60\uff1f"},"content":{"rendered":"<div>\n<div>\n<div>\n<h1>                  \u6709\u4ec0\u4e48 vue3+typescript \u5f00\u53d1\u7684\u7ec4\u4ef6\uff0c\u53d1\u5e03\u4e3a npm \u5305\u7684\u8be6\u5c3d\u6307\u5357\u53ef\u4f9b\u5b66\u4e60\uff1f               <\/h1>\n<p> <\/p>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : Shook <\/span>  <span><i><\/i> 17<\/span> <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<\/p><\/div>\n<div isfirst=\"1\"> <\/p>\n<p>\u60f3\u8981\u7ec3\u7ec3\u624b\u5199\u4e0b composition api\uff0c\u641c\u7f57\u4e86\u5f88\u591a\u8d44\u6599\u3002 \u6807\u7b7e\u9875\u90fd\u5f00\u4e86\u4e94\u5341\u591a\u4e2a\uff0c\u6700\u540e\u8fd8\u662f\u88ab vue-cli + vue3 + typescript \u7ec4\u5408\u62f3\u51fb\u5012\u4e86\u3002 \u6574\u7406\u4e86\u4e00\u4e9b\u95ee\u9898\uff0c\u4eca\u665a\u8fd8\u8981\u7ee7\u7eed\u770b\uff0c\u5e0c\u671b\u6709\u7ecf\u9a8c\u7684\u524d\u8f88\u80fd\u591f\u56de\u7b54\u4e00\u4e0b\uff1a<\/p>\n<h3><strong>UI \u5e93\u4e0e\u5b50\u7ec4\u4ef6\u5982\u4f55\u7ec4\u5408\u53d1\u5e03\uff1f<\/strong><\/h3>\n<p>\u6bd4\u65b9\u8bf4\u6211\u60f3\u8981\u5f00\u53d1\u4e00\u4e2a UI \u5e93\uff0c\u4f46\u662f\u5b83\u5728\u6700\u5f00\u59cb\u53ea\u6709\u96f6\u661f\u7684\u7ec4\u4ef6\u53ef\u4f9b\u4f7f\u7528\u3002 \u8fd9\u65f6\u5019\uff0c\u6211\u80fd\u5426\u5c06 UI \u5e93\u548c\u7ec4\u4ef6\u5206\u522b\u4f5c\u4e3a NPM \u5305\u53d1\u5e03\uff1f \u867d\u7136\u6211\u5e0c\u671b\u7ed3\u679c\u662f\u8fd9\u6837\u7684\uff0c\u4f46\u662f\u60f3\u4e0d\u5230\u600e\u4e48\u505a\uff1a<\/p>\n<pre><code>npm install @vueui \/\/ UI \u5e93\uff0c\u66b4\u9732\u5f80\u6839\u90e8 vue \u5b9e\u4f8b\u6302\u8f7d UI \u5e93\u6240\u6709\u7ec4\u4ef6\u7684 install \u65b9\u6cd5 npm install @vueui\/confirm \/\/ vue \u7ec4\u4ef6\uff0c\u66b4\u9732\u6302\u8f7d\u5355\u72ec\u7ec4\u4ef6\u7684 install \u65b9\u6cd5 <\/code><\/pre>\n<p>\u8fd9\u6837\u7684\u8bdd\uff0cpackage.json \u548c tsconfig.json \u8fd9\u4e9b\u914d\u7f6e\u6587\u4ef6\u8be5\u600e\u4e48\u529e\u5462\uff0c\u4e5f\u8981\u5d4c\u5957\u5417\uff1f \u8fd8\u662f\u8bf4\u53ea\u80fd\u5199\u5b8c\u4e86\u5c06\u6587\u4ef6\u590d\u5236\u5230\u4e00\u4e2a\u4e13\u95e8\u53d1\u5e03 vue \u7ec4\u4ef6\u7684\u6a21\u677f\u4e2d\uff0c\u7136\u540e\u5355\u72ec\u53d1\u5e03\uff1f<\/p>\n<h3><strong>vue3 + typescript \u5199\u7684\u7ec4\u4ef6\uff0c\u53d1\u5e03\u524d\u9700\u8981\u505a\u4ec0\u4e48\u5904\u7406\uff1f<\/strong><\/h3>\n<p>\u5728\u641c\u7f57\u5230\u7684\u6587\u7ae0\u91cc\uff0c\u57fa\u672c\u63d0\u5230\u4e86\u7ec4\u4ef6\u8981\u5206\u6210 src \u548c dist \u4e24\u4e2a\u6587\u4ef6\u5939\uff0cdist \u6587\u4ef6\u5939\u7528\u4e8e\u5b58\u653e\u6253\u5305\u6210.js \u7684\u7ec4\u4ef6\u3002 \u4e0d\u8fc7\u4ed6\u4eec\u6709\u7684\u4f7f\u7528 rollup \u6765\u6253\u5305\uff0c\u6709\u7684\u76f4\u63a5\u4f7f\u7528 vue-cli-service build\uff0c\u8fd9\u4e24\u79cd\u65b9\u5f0f\u6709\u4ec0\u4e48\u533a\u522b\u5417\uff1f<\/p>\n<p>\u5173\u4e8e typescript \u7684\u95ee\u9898\u5c31\u662f\u4e0d\u61c2 d.ts \u662f\u4e00\u5b9a\u8981\u5199\u7684\u5417\uff0c\u9700\u8981\u628a\u81ea\u5df1\u5728.vue \u91cc\u9762\u5199\u7684\u7c7b\u578b\u58f0\u660e\u63d0\u53d6\u51fa\u6765\u5417\uff1f \u5982\u679c\u63d0\u51fa\u6765\uff0c\u6211\u8be5\u628a\u8fd9\u4e2a\u6587\u4ef6\u5f15\u5165 \/\u58f0\u660e\u5230\u4ec0\u4e48\u5730\u65b9\uff0c\u624d\u80fd\u8ba9\u6211\u5728.vue \u91cc\u5199\u4ee3\u7801\u7684\u65f6\u5019\u80fd\u591f\u8bc6\u522b interface \u5462\uff1f<\/p>\n<h3><strong>vue3 \u91cc\u5982\u4f55\u7ec4\u7ec7\u4ee3\u7801\uff1f<\/strong><\/h3>\n<p>\u5728\u4f7f\u7528 composition api + typescript \u8fdb\u884c\u5f00\u53d1\u65f6\uff0c\u6211\u6709\u591a\u6b21\u56e0\u4e3a\u4ee3\u7801\u7ed3\u6784\u6742\u4e71\u611f\u5230\u5c3f\u6025\uff0c\u6bd4\u5982\uff1a<\/p>\n<pre><code>setup () {  \/\/ vue3 composition api \u7ed1\u5b9a $refs \u7684\u65b9\u6cd5\uff0c\u6bd4\u8f83\u5947\u602a\u7684  const wrap: any = ref(null);   \/\/ \u76f4\u63a5\u5b9a\u4e49\u4e00\u4e2a\u65b9\u6cd5  function getWrap (): HTMLElement | null {   return wrap.value ? wrap.value : null;  }   \/\/ \u5b9a\u4e49\u63a5\u53e3\u5e76\u5b9e\u73b0(\u5982\u679c\u6211\u505a\u9519\u4e86\uff0c\u8bf7\u7ea0\u6b63\u6211)  interface getWrap {   (): HTMLElement | null;  }  const getWrap: getWrap = () =&gt; wrap.value ? wrap.value : null;   return {   wrap,  }; } <\/code><\/pre>\n<p>\u5b9e\u73b0\u63a5\u53e3\u65f6\u662f\u4e0d\u662f\u53ea\u80fd\u591f\u4ee5\u521d\u59cb\u5316\u53d8\u91cf\u7684\u5f62\u5f0f\u6765\u5b9e\u73b0\uff1f \u8fd9\u6837\u7684\u8bdd\u6ee1\u5c4f\u5c31\u90fd\u662f const \u4e86\u3002 \u5c06\u63a5\u53e3\u90e8\u5206\u5355\u72ec\u5199\u6210\u6587\u4ef6\u540e\uff0c\u4e5f\u56e0\u4e3a\u4e0d\u61c2\u5728\u54ea\u5f15\u5165\uff0c\u597d\u597d\u53d1\u6101\u4e86\u4e00\u6bb5\u65f6\u95f4\u3002<\/p>\n<h3><strong>\u4e00\u4e9b\u641c\u96c6<\/strong><\/h3>\n<p>\u4e5f\u8bb8\u662f\u8bb8\u591a\u65b0\u4e8b\u7269\u4e00\u4e0b\u5b50\u6d8c\u5165\u5927\u8111\uff0c\u6240\u4ee5\u6211\u73b0\u5728\u6bd4\u8f83\u96be\u8f6c\u8fc7\u5f2f\u6765\uff0c\u53d1\u8fd9\u4e2a\u5e16\u5b50\u6216\u8bb8\u80fd\u591f\u5e2e\u52a9\u6211\u6574\u7406\u4e00\u4e0b\u8981\u505a\u7684\u4e8b\u60c5\u3002 \u653e\u4e0a\u4e00\u4e9b\u641c\u5230\u7684\u8d44\u6599\uff0c\u6216\u8bb8\u80fd\u5e2e\u5230\u4e00\u4e9b\u6bd4\u8f83\u806a\u660e\u7684\u670b\u53cb\u3002<\/p>\n<ul>\n<li>https:\/\/zhuanlan.zhihu.com\/p\/38110493<\/li>\n<li>https:\/\/zhuanlan.zhihu.com\/p\/46273917<\/li>\n<li>https:\/\/www.cnblogs.com\/tongjiaojiao\/p\/10191627.html<\/li>\n<\/ul><\/div>\n<div> <b>\u5927\u4f6c\u6709\u8a71\u8aaa<\/b> (<span>1<\/span>)        <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<ul>\n<li data-pid=\"3032127\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : agdhole <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u53ef\u4ee5\u53c2\u8003 vuetify \u6b63\u5728\u5f00\u53d1\u7684 v3 \u5206\u652f\uff0cts + vue3<br \/>https:\/\/github.com\/vuetifyjs\/vuetify\/tree\/next                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li>\n","protected":false},"excerpt":{"rendered":"<p>\u6709\u4ec0\u4e48 vue3+typescri&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\/150608"}],"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=150608"}],"version-history":[{"count":0,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/150608\/revisions"}],"wp:attachment":[{"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=150608"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=150608"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=150608"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}