首页 > 解决方案 > Vue-Router 在谷歌 ADS 中返回 404

问题描述

我在为我的项目设置谷歌广告时遇到了一些问题。我的 vue 路由器在历史模式下工作,当我直接打开任何 URL(例如mysite.com/category/phone)时,它工作正常。但是在 ads.google.com 中,当我尝试将这些 URL 添加为目标时,它被拒绝了,因为 google 在对这些 URL 的 HTTP 请求中收到错误 404。也许是因为我在 Yii2 模板中使用了 Vue.js 应用程序?此外,我正在接收元标记和一些需要在路由器初始化之前从后端提供的 URL。

Vue.axios.get('/api/meta').then(response => {
   const routes = [...defining routes here...];
   ...
   const router = new VueRouter ({
    mode: 'history',
    routes,
    scrollBehavior (to, from, savedPosition) {
        return { x: 0, y: 0 };
    }
   });


  const app = new Vue({
    template: '',
    router,
  }).$mount('#app');

});

标签: javascriptvue.jshttpgoogle-analytics

解决方案


推荐阅读