js 共用文件内容应用

在js文件内

const current = 'dev' //当前选择的对象类型
const config = { //全部的对象类型
'dev':{ //测试
'one':'https',
'two':'https',
'three':'appid',
'four':'id'
},
'prod':{ //正式
'one':'https',
'two':'https',
'three':'appid',
'four':'id'
}
}

const config = config[current]; //config 等于 config数组里的 "当前对象"
module.exports = config; //暴露config接口,使别的页面可以引用

 

 

在引用的vue文件内

<template>
<view>
{{config}}
</view>
</template>

<script>

import Config from "add.js"; //引入add.js文件。

export default {
data() {
return {
config:null,
}
},

onShow(){

this.config = Config
console.log(this.config);

},

}

</script>

 

posted @ 2021-04-21 17:42  伊人兮明眸秋水  阅读(88)  评论(0编辑  收藏  举报