• 赚钱入口【需求资源】限时招募流量主、渠道主,站长合作;【合作模式】CPS长期分成,一次推广永久有收益。主动打款,不扣量;

Uncaught TypeError: Cannot redefine property: $router

Vue cps12345 4个月前 (08-07) 53次浏览 0个评论

错误如下:

Uncaught TypeError: Cannot redefine property: $router
at Function.defineProperty ()
at Function.install (VM2179 vue-router.esm.js:526)
at Function.Vue.use (vue.js:4738)
at eval (VM2179 vue-router.esm.js:2447)
at Object../node_modules/vue-router/dist/vue-router.esm.js (VM2105 app.js:1615)
at __webpack_require__ (VM2105 app.js:712)
at fn (VM2105 app.js:95)
at eval (VM2178 index.js:3)
at Object../src/router/index.js (VM2105 app.js:2415)
at __webpack_require__ (VM2105 app.js:712)

index.js文件如下:

import Vue from 'vue'
import Router from 'vue-router'
import Blog from '../components/Blog.vue'
import BlogPost from '../components/BlogPost.vue'

Vue.use(Router)
Vue.config.silent = true

export default new Router({
  routes: [
    {
      path: '/blog',
      name: 'Blog',
      component: Blog
    },
    {
      path: '/blog/:slug',
      name: 'Blog-post',
      component: BlogPost
    }
  ]
})

app.ts如下:

import Vue from 'vue'
import App from './App.vue'
import router from './router'
import store from './store/simple_store'
import '../assets/app.css'
import './assets/main_logo.css'
import './assets/pages/page_header_animation.css'

new Vue({
  el: '#app',
  router,
  store,
  render: h => h(App)
})

解决方案

在index.html文件中,再次导入vue:

<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width,initial-scale=1.0">
    <title>Meko Deng</title>
  </head>
  <body>
    <div id="app"></div>
    <!-- <script src="https://cdn.jsdelivr.net/npm/vue@2.5.16/dist/vue.js"></script> -->
</body>
</html>
喜欢 (0)
发表我的评论
取消评论
表情 贴图 加粗 删除线 居中 斜体 签到

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址