将axios url请求写成配置文件
在public目录中新建js
baseurl.js
const getUrl='http://localhost:9999/test/test'
console.log(getUrl)
index引用
<script src="./baseurl.js"></script>
在vue页面中可直接引用getUrl
methods:{
get(){
let baseurl = getUrl
this.$http({ method: 'get', url:baseurl , params: data}).then(
(resp) => {
console.log(resp.data)
this.$refs.trc.get(resp.data)
this.$refs.title.getTitle(acode1,resp.data.newtime)
}, (error) => {
console.log('error=' + JSON.stringify(error))
}).catch((exception) => {
})
}
}