How to introduce public method files encapsulated by themselves in vue-cli?

I fetched the package in main.js. Why can"t other vue components call the methods directly?

clipboard.png

clipboard.png

Mar.20,2021

.vue is to be compiled and messed around by webpack , not to mention the details.

is usually injected with plug-ins:

ide/plugins.html" rel=" nofollow noreferrer "> plug-in-- Vue.js


can be mounted on the prototype Vue.prototype.$ajax


is usually called in the form of a plug-in to install, and then. Of course, I think you can directly import {post} from'. Then mount it to the vue prototype. There is no need for install. If you want to figure out how this install is implemented, you can take a look at the loading,msg implementation under the ui framework and see how they expose the install method.


I suspect you are on the wrong path. This is also a project built by vue-cli. Isn't it . / utils/http that you were introduced into your file path from main.js.

// main.js
import { post } from './utils/http'
Vue.prototype.$post = post

//  ok
this.$post(xxxxxxxx)
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b3801f-2b858.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b3801f-2b858.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?