ZGLHHH
V2EX  ›  问与答

Vue.js 如何加载一个带有 v-link 的 template?

  •  
  •   ZGLHHH · Apr 28, 2016 · 4146 views
    This topic created in 3721 days ago, the information mentioned may be changed or developed.
    我目前在写的一个个人项目需要用到 vue.js & Laravel

    使用 vue.js 写前端

    目前遇到了个百思不得其解的问题: Vue.js 如何加载一个带有 v-link 的 template ?

    代码如下:
    .js

    如果这样写,会遇到错误
    [vue-router] v-link can only be used inside a router-enabled app.
    Uncaught TypeError: Cannot read property 'stringifyPath' of undefined
    https://ooo.0o0.ooo/2016/04/28/57220f67251ac.png

    实在搞不懂了,在 header.vue 引入 vue 和 vue-routery 也不行……
    4 replies    2016-04-30 11:27:08 +08:00
    horizon
        1
    horizon  
       Apr 29, 2016 via iPhone
    直接用 href ,这是因为你没引入 Vue router 吧
    ZGLHHH
        2
    ZGLHHH  
    OP
       Apr 29, 2016
    @horizon 在 header.vue 引入了:
    <script>
    import Vue from 'vue';
    import VueRouter from "vue-router";
    var VueResource = require('vue-resource');
    Vue.use(VueRouter);
    Vue.use(VueResource);
    export default{

    }
    </script>

    一样的错误……
    horizon
        3
    horizon  
       Apr 29, 2016 via iPhone   ❤️ 1
    @ZGLHHH 还有 vue.start 呢?好好看看文档
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   3721 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 34ms · UTC 04:40 · PVG 12:40 · LAX 21:40 · JFK 00:40
    ♥ Do have faith in what you're doing.