1. Fill in the global config.js
function getConfig(str){ var ajaxurl = "http://112.80.39.92:8008/webservices/rest.php?version=1.1"//测试 // var ajaxurl = "http://112.80.39.92:8018/webservices/rest.php?version=1.1"//生产 switch(str){ case "ajaxurl": return ajaxurl break; } } // exposed method // public method export default { getConfig:getConfig,//Get public configuration method }
main.js introduces the current file
import getMyConfig from './assets/js/config'
Vue.prototype.$getMyConfig = getMyConfig;//When the configuration file is introduced , the usage method
can be used globally
var ajaxurl = this.$getMyConfig.getConfig('ajaxurl');
get the url path