【问题标题】:Don't see a div into a vue component看不到 div 进入 vue 组件
【发布时间】:2019-07-12 03:07:12
【问题描述】:

我有一个带有 div 和一个按钮的 vue 组件,进入另一个 div 我有两个组件

<script>
    export default {
        name: 'excursion-backend-component',
        methods:{
            doRedirection: function () {
                window.location = APP_URL+"/excursiones/create";
            }
        },
        mounted() {
            console.log(APP_URL+"/excursiones/create");
            console.log("aaaa");
        }
    }
</script>
<template>
    <div class="container">
        <h3>Adicionar excursi&oacute;n</h3>
        <div style="text-align: right">
            <a class="btn btn-primary" :href="doRedirection"><i class="fa fa-plus"></i> Adicionar</a>
        </div>
        <br>

        <div>
            <excursion-list-component></excursion-list-component>
            <excursion-add-component></excursion-add-component>
        </div>
    </div>
</template>

但我没有看到导航器上的按钮。

怎么了?

Here is how I see the page

【问题讨论】:

  • Ufff 对不起,我在 view laravel 上调用了 excursion-list-component 组件。正确的做法是放通用组件。 (版主。如果你想删除这个问题......)
  • 如果您认为这是一个好问题并且对其他用户有帮助,您可以回答自己的问题。如果这是一个基本的错字,那么我会投票关闭它。

标签: laravel button vue.js components


【解决方案1】:

:href="" 期望带有导航 URL 的字符串,但您使用的是方法。

如果您想使用方法,请改用@click :href。

<a @click="doRedirect">... </a>

或者,可能是,将其移动到计算块

computed: {
    excursionesUrl () {
      return APP_URL+"/excursiones/create";
   }
}

【讨论】:

    猜你喜欢
    • 2018-10-24
    • 2020-05-08
    • 2017-11-07
    • 2017-05-18
    • 2022-01-12
    • 2019-02-05
    • 2020-02-26
    • 2020-12-23
    • 2018-07-14
    相关资源
    最近更新 更多