1. 程式人生 > >vue 使用全域性資料

vue 使用全域性資料

1.新建一個存放全域性資料的all.js檔案

const con={
    http:'www.1111.com',
    title:'i am goloab data'
}
//介面暴露
export default{
con
}

2.在main.js中引用

import Vue from 'vue'
import Con from'./http/http'
Vue.prototype.getCon = Con.con

3.頁面中使用

<template>
    {{message}}
    <a :href='http'></a>
</template>
<script>
    export default{
        data(){
        return{
        message:this.getCon
}    
}
}
</script>