{"id":270160,"date":"2021-01-11T07:35:45","date_gmt":"2021-01-10T23:35:45","guid":{"rendered":"http:\/\/4563.org\/?p=270160"},"modified":"2021-01-11T07:35:45","modified_gmt":"2021-01-10T23:35:45","slug":"vue-%e9%87%8c%e9%9d%a2%e5%bc%95%e5%85%a5%e7%ac%ac%e4%b8%89%e6%96%b9%e6%8f%92%e4%bb%b6%e9%94%99%e8%af%af","status":"publish","type":"post","link":"http:\/\/4563.org\/?p=270160","title":{"rendered":"Vue \u91cc\u9762\u5f15\u5165\u7b2c\u4e09\u65b9\u63d2\u4ef6\u9519\u8bef"},"content":{"rendered":"<div>\n<div>\n<div>\n<h1>                  Vue \u91cc\u9762\u5f15\u5165\u7b2c\u4e09\u65b9\u63d2\u4ef6\u9519\u8bef               <\/h1>\n<p> <\/p>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : alexmao <\/span>  <span><i><\/i> 2<\/span> <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<\/p><\/div>\n<div isfirst=\"1\"> <\/p>\n<p>\u4eca\u5929\u4e0b\u5348\u6298\u817e\u4e86\u597d\u4e45\u4e00\u4e2a\u9519\u8bef\uff0c\u7ed3\u679c\u8fd8\u662f\u6ca1\u89e3\u51b3\u3002 \u6211\u9700\u8981\u5b89\u88c5\u4e00\u4e2a toast \u63d2\u4ef6\uff0c\u5728 npmjs \u91cc\u9762\u627e\u5230\u4e86\u5f88\u591a\u4e2a toast \u63d2\u4ef6\uff0c\u6700\u7ec8\u5b89\u88c5\u8fd9\u4e2a vue2-toastr\uff0c\u4f46\u662f\u5b89\u88c5\u4e86\u5e76\u5bfc\u5165\u7684\u65f6\u5019\uff0c\u5c31\u4e00\u76f4\u51fa\u73b0\u8fd9\u4e2a\u62a5\u9519\u3002\u8bf7 V2 \u91cc\u5404\u4f4d\u5927\u4f6c\u5e2e\u5fd9\u770b\u4e00\u773c\u53ef\u80fd\u662f\u4ec0\u4e48\u95ee\u9898\uff1f<\/p>\n<pre><code>vue2-toastr.js:1 Uncaught TypeError: Cannot set property '$toast' of undefined   at Object.install (vue2-toastr.js:1)   at Object.use (runtime-core.esm-bundler.js:3063)   at eval (main.js:21)   at Module..\/src\/main.js (app.js:1148)   at __webpack_require__ (app.js:849)   at fn (app.js:151)   at Object.1 (app.js:1161)   at __webpack_require__ (app.js:849)   at checkDeferredModules (app.js:46)   at app.js:925 <\/code><\/pre>\n<p>main.js \u6587\u4ef6\u5185\u5bb9\u5982\u4e0b\uff1a<\/p>\n<pre><code>import { createApp } from 'vue' import App from '.\/App.vue' import Toastr from 'vue2-toastr'  createApp(App).use(Toastr).mount('#app') <\/code><\/pre>\n<p>\u611f\u8c22\uff01<\/p>\n<\/p><\/div>\n<div> <b>\u5927\u4f6c\u6709\u8a71\u8aaa<\/b> (<span>10<\/span>)        <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<ul>\n<li data-pid=\"4894991\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : renmu123 <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u5e94\u8be5 vue3 \u548c vue2 \u7684\u7ec4\u4ef6\u4e0d\u517c\u5bb9                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"4894992\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : wgbx <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u611f\u89c9\u662f\u4e0d\u517c\u5bb9\uff0c\u8fd9\u79cd\u7ec4\u4ef6\uff0c\u8981\u4e0d\u627e\u4e00\u4e2a\u5927\u516c\u53f8\u7684\uff0c\u8d70\u6309\u9700\u5f15\u7528\uff0c\u8981\u4e0d\u81ea\u5df1\u5199\uff0c\u5f15\u7528\u8fd9\u79cd\u5c0f\u5e93\uff0c\u5bb9\u6613\u51fa\u73b0\u95ee\u9898                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"4894993\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : alexmao <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @renmu123 \u61c2\u4e86\uff0c\u8c22\u8c22\uff01                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"4894994\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : alexmao <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @wgbx \u597d\u7684\uff0c\u4e0d\u77e5\u9053 toast \u6709\u6ca1\u6709\u5927\u516c\u53f8\u7684\u7ec4\u4ef6\uff1f                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"4894995\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : yetone <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             Vue \u8fd9\u79cd\u7c7b\u578b\u4e0d\u5b89\u5168\u7684\u6846\u67b6\u771f\u7684\u662f\u4e00\u8a00\u96be\u5c3d\u2026\u2026                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"4894996\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : suzic <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u4f60\u662f vue3 \u7684\u3002\u76ee\u524d\u786e\u5b9a vant3.x \u80fd\u6ee1\u8db3\u4f60\u7684\u9700\u6c42\uff0c\u914d\u4e00\u4e0b\u6309\u9700\u5f15\u5165\u5176\u5b9e\u4e5f\u6ca1\u591a\u5927                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"4894997\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : 320266360 <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @alexmao mint-ui \u91cc\u9762\u6709 toast \u6309\u9700\u52a0\u8f7d\u5c31\u53ef\u4ee5\u7528\u3002                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"4894998\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : H15018327040 <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             vue3 \u8bbe\u7f6e\u4e0d\u652f\u6301 Vue.prototype.$toast=toast \u8fd9\u79cd\u65b9\u5f0f\uff0c\u5982\u679c\u8981\u4f7f\u7528\u5168\u5c40\u5c5e\u6027\uff0c\u53ef\u4ee5\u901a\u8fc7 Vue3 \u7684 let app=createApp()\uff0capp.global.properties.$toast=toast \u8fd9\u79cd\u65b9\u5f0f\uff0c\u4e5f\u4e0d\u80fd\u4f7f\u7528 this.$toast \u8fd9\u79cd\u65b9\u5f0f\u4f7f\u7528\u3002                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"4894999\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : H15018327040 <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u8bb0\u5c94\u4e86\uff0c\u662f app.config.globalProperties                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"4895000\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : learningman <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @H15018327040 \u6211\u5b9e\u6d4b\u662f\u53ef\u4ee5\u7684\u554a\u3002\u3002\u3002                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li>\n","protected":false},"excerpt":{"rendered":"<p>Vue \u91cc\u9762\u5f15\u5165\u7b2c\u4e09\u65b9\u63d2\u4ef6\u9519\u8bef \u8cc7&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\/270160"}],"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=270160"}],"version-history":[{"count":0,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/270160\/revisions"}],"wp:attachment":[{"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=270160"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=270160"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=270160"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}