search

Home  >  Q&A  >  body text

javascript - Why does my router-link in vue not work?

<template>
  <p id="app">
      <headers></headers>
          <p class="tap">
              
          <p class="tab-item">
          <router-link to="/goods">第一项</router-link>
        </p>
        <p class="tab-item">
          <router-link to="/ratings">第二项</router-link>
        </p>
        <p class="tab-item">
          <router-link to="/seller">第三项</router-link>
        </p>
        
        <router-view></router-view> 
      </p>
  </p>
</template>
<script>
import headers from './components/header/header';
    
export default {
    components:{
        headers
    },
  name: 'app',
};
</script>

This is the content of App.vue. In fact, the page display has been mounted as a tag, but clicking has no effect, and there is no effect of clicking to change components

<template>
    <p id="goods">
        <p @:click="say()">
            ssssss
        </p>
    </p>
</template>

<script>
    export default{
        name:{
            'goods'
        },
        method:{
            say:{
                console.log('sayhi');
            }
        }
    }
</script>

This is the code for one of the routers. The other two are basically the same. How to get the effect?

漂亮男人漂亮男人2755 days ago689

reply all(2)I'll reply

  • 黄舟

    黄舟2017-05-16 13:40:06

    1. Is the routing path correct?
    2. The method is written wrong, methods
    3. The function say( ){} or say: function(){} should be written below methods
    4.@:click should be @click

    reply
    0
  • 漂亮男人

    漂亮男人2017-05-16 13:40:06

    0.0.00.00.

    reply
    0
  • Cancelreply