vue-cli中history模式如何配置assetsPublicPath

使用vue-router的history模式后,assetsPublicPath定位错误,有什么办法可以解决吗?

// router 配置
const HistoryTest = () => import('@/components/HistoryTest')
Vue.use(Router)

export default new Router({
  mode: 'history',
  routes: [
    {
      path: '/root/file',
      name: 'HistoryTest',
      component: HistoryTest,
    },
  ],
})

// HistoryText组件中
<img src="static/logo.png" alt="">

// 实际请求的URL
Request URL:http://localhost:48080/root/static/logo.png
阅读 6.1k
1 个回答

应该是<img src="static/logo.png" alt=""> ,少了个/

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题