最新亚洲精品福利在线,欧美一区二区三区大片,久久91无码一区二区三区,色哟哟免费观看视频入口,美女裸露双奶头屁股无裸体

通過vue.use來加載自定義的vue插件

時間:2019-09-08 11:23:16 類型:vue
字號:    

1. 在components下定義pub.js  

//方法1 
exports.install = function (Vue, options) {
      Vue.prototype.baseUrl = 'http://www.858876.cn/';
      Vue.prototype.getMyname = function(){
                console.log("南昌雅騰")
      }
 };
//方法2
export default{
    install(Vue,options){
        Vue.prototype.baseUrl = 'http://www.858876.cn/';
        Vue.prototype.getMyname = function(){
                  console.log("南昌雅騰")
        }
    }
}

2. 在main.js/main.ts文件中引用 


import pub from './components/pub';
  Vue.use(pub);
3. 在.vue文件中調(diào)用
 console.log(this.baseUrl);
 this.getMyname();