vue

1.去掉地址栏的#号
export default new Router({
mode: 'history',//去掉地址栏#号
routes: [
{
path: '/',
name: 'HelloWorld',
component: HelloWorld
},
{
path: '/homepage',
component: homepage
}
]
})
2.跨域获取数据
proxyTable: {
'/apis': {
// 测试环境 target: 'https://goods.footer.com',
// 接口域名 changeOrigin: true,
//是否跨域 pathRewrite: {
'^/apis': '' //需要rewrite重写的,
} } },
//配置$http,下载vue-resource,然后在main.js中
import Vueresource from 'vue-resource'
Vue.use(Vueresource)
然后就可以直接使:
this.$http.get( '/apis/health/list',{params: obj}) .then(function(res){ // 成功回调 },function(){ alert("error") })
原文地址:https://www.cnblogs.com/liangru/p/8744821.html